0

I have multiple HQL's, below is the one example.

located at : /home/ganesh/CopyJobs/hql/

insert into XYZ.exttbl_form_data PARTITION (load_date="$proc_date") select FORM_DATA_ID,FORM_ID,USER_ID,INTERACTIONS_ID,SUBMISSION_DATETIME,FILEDS from PQR.exttbl_form_data where load_date="$proc_date" 

In the main script im reading above mentioned HQLs as

export proc_date=2018-05-07

while read line
do
export hql=`cat /home/ganesh/CopyJobs/hql/$table_name.hql`

export hql_final=$(`eval echo"$hql"`)
echo "Final HQL: $hql_final"
hive -e "$hql_final;"

done < /home/ganesh/CopyJobs/config/tables.txt 

where in tables.txt has list of all HQL.

I want to resolve the $proc_date however that not happening.

  • Where are you using your $line value? – Kusalananda May 10 '18 at 6:16
  • 1) in export hql=cat /home/ganesh/CopyJobs/hql/$table_name.hql $table_name.hql in undefined. 2) cat will not replace $proc_date's value. – Archemar May 10 '18 at 6:40
0

I am not sure $(eval echo"$hql") is a good choice.

  • add a space between echo and "$hql"
  • there are no less than four substitution here, I would have use 3 lines.

I would template hql file, e.g. replace load_date="$proc_date" by LOAD_DATA_TMPL

then, inside the loop

hql_final=$(sed s:LOAD_DATA_TMPL:load_date="$proc_date":g /home/ganesh/...)
echo "Final HQL: $hql_final"
hive -e "$hql_final;"
  • be sure there is no space in $proc_date

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.