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
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
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}
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'