4

I am trying to pass command line arguments through the below ,but its not working . Can anybody help me with what I am doing wrong here!

hive -f test2.hql -hiveconf partition=20170117 -hiveconf -hiveconf datepartition=20170120 
franklinsijo
  • 17,784
  • 4
  • 45
  • 63
Babu
  • 861
  • 3
  • 13
  • 36

2 Answers2

2

Pass your arguments before the query file,

hive --hiveconf partition='20170117' --hiveconf datepartition='20170120' -f test2.hql 

And use them in your queries in test2.hql like this,

${hiveconf:partition}

Example:

select * from tablename where partition=${hiveconf:partition} and date=${hiveconf:datepartition}
franklinsijo
  • 17,784
  • 4
  • 45
  • 63
0

Some alternatives:

1) if using hive command line, you can just elaborate the whole sql command and execute it like:

hive -e <command>

and explicit the parameters as literals.

2) if using beeline (preferred to hive), just append this to the command line:

--hivevar myparam='myvalue'
peleitor
  • 459
  • 7
  • 24