Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing date as command line arguments in Hive

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

like image 896
arsenal Avatar asked Aug 03 '12 22:08

arsenal


People also ask

How do I select a date in Hive?

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.

How does Hive determine date format?

The default date format of Hive is yyyy-MM-dd , and for Timestamp yyyy-MM-dd HH:mm:ss .

What is Hiveconf?

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.


1 Answers

Eliminate the space between hiveconf: and start_date.

This may only be for string types, but Hive is picky in this respect.

like image 177
Carter Shanklin Avatar answered Oct 13 '22 00:10

Carter Shanklin