I have my below query in test1.hql file
. I am trying to pass the date (dt)
as the command line argument.
select * from lip_data_quality where dt = '${hiveconf: start_date}';
So whenever I try to run the above test1.hql
file from shell prompt like this-
hive -f hivetest1.hql -hiveconf start_date=20120709
I get zero records back. But the data is there in that table for that particular date. Why is it so? Something wrong I am doing?
Can anyone help me out here? I was following Bejoy's Article
I am working Hive 0.6
Solution. CURRENT_DATE will give the current date and CURRENT_TIMESTAMP will give you the date and time. If you want to work with EPOCH time then use unix_timestamp() to get the EPOCH time and use from_unixtime to convert EPOCH to date and time.
The default date format of Hive is yyyy-MM-dd , and for Timestamp yyyy-MM-dd HH:mm:ss .
hiveconf – is the default namespace when you set variables. hivevar – is the default namespace when you refer to the variables. To conclude, to avoid this confusion, always prefix your variables with the namespace and we recommend you using hivevar namespace when your intention is to use the variables in Hive scripts.
Eliminate the space between hiveconf: and start_date.
This may only be for string types, but Hive is picky in this respect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With