Created 03-19-2016 01:27 PM
Hi:
I am trying to execute this and pass the parameter "20160301" to beeline script but doesnt work:
beeline -u jdbc:hive2://hostname:10000 -n xxxx -p xxxx -f /home/hdfs/scripts/hive/store_wordcount.hql 20160301
Any idea how to pas this parameter??
Thanks
Created 03-19-2016 06:19 PM
The correct way has changed a bit. You shouldn't use hiveconf as is shown in the link since it sets parameters and is restricted when you use something like SQLStdAuth.
The correct way to do it is
beeline -u jdbc:hive2://hostname:10000 -n xxxx -p xxxx -f /home/hdfs/scripts/hive/store_wordcount.hql --hivevar day=20160301
You can then use this variable as ${day} in the SQL script. hivevars are only variables, hiveconf could also be settings like mapreduce.map.memory.mb.
Created 03-19-2016 06:19 PM
The correct way has changed a bit. You shouldn't use hiveconf as is shown in the link since it sets parameters and is restricted when you use something like SQLStdAuth.
The correct way to do it is
beeline -u jdbc:hive2://hostname:10000 -n xxxx -p xxxx -f /home/hdfs/scripts/hive/store_wordcount.hql --hivevar day=20160301
You can then use this variable as ${day} in the SQL script. hivevars are only variables, hiveconf could also be settings like mapreduce.map.memory.mb.
Created 03-19-2016 06:53 PM
Hi:
I tried it but not working well look:
beeline -u jdbc:hive2://hostname:10000 -n xxxx -p xxxx -f /home/hdfs/scripts/hive/store_wordcount.hql --hivevar day=2016/3/01 and inside de hql script that LOAD DATA INPATH '/RSI/staging/output/wordcount/${day}' OVERWRITE INTO TABLE temp_wordcount_v3;
the output is.
Error: Error while compiling statement: FAILED: SemanticException Line 1:17 Invalid path ''/RSI/staging/output/wordcount//3/'': No files matching path hdfs://lnxbig05.cajarural.gcr:8020/RSI/staging/output/wordcount/3 (state=42000,code=40000)
Created 03-19-2016 07:25 PM
Hi:
finally its works like this: with double comillas
RUTAHIVE=$ANYODIR"/"${BATCH:2:1}"/"${BATCH:3}"" beeline -u jdbc:hive2://hostname:10000 -n hive -p temporal01 -f /home/hdfs/scripts/hive/store_wordcount.hql --hivevar date=$RUTAHIVE
Created 03-19-2016 08:22 PM
Good that you figured it out. You weren't using special characters in the original question. So yes the parameter needs to be in quotes if the values are not normal letters. You might also have to escape things sometimes.
i.e.
--hivevar "day=2016/3/01"
--hivevar "regex=.*\\|" ( if you want the regex .*\| )
And if you use it in shell scripts you sometimes have to escape more. I once needed 32 \\ in oozie to have 1 backslash in a pig script.