Hi, I have following shell script:

#!/bin/bash
PNAME=20170320_203225
TNAME=tablea1
/usr/bin/hive -hiveconf hive.cli.errors.ignore=true -hivevar PNAME=$PNAME 
-hivevar TNAME=$TNAME -v -f ./query.hql

Trying to pass PNAME hivevar to query.hql script:

insert into table a1.${hivevar:TNAME}_orc PARTITION (part_col=${hivevar=PNAME})
select
a1,
a2,
a3
from a1.${hivevar:TNAME}
;

Substitution works fine in table name and from clause. However in 
(part_col=${hivevar=PNAME}) I get error cannot recognize input near '$' '{' 
'hivevar' in constant.

If I add quotes (part_col="${hivevar=PNAME}"), it works fine, but never expands 
variable, resulting having text "${hivevar=PNAME}") in my partition.
How should I quote PNAME to avoid error and having my variable expanded?

Can anyone help?
Thank you!

Reply via email to