Techy Teck 2012-08-06, 18:10
Yue Guan 2012-08-06, 19:00
carla.staeben@... 2012-08-06, 19:23
Techy Teck 2012-08-06, 19:30
carla.staeben@... 2012-08-06, 23:26
-RE: (Get the current date -1) in Hive
Venkatesh Kavuluri 2012-08-07, 20:28
Since the UDF unix_timestamp() is a non-deterministic function, Hive query planner doesn't run partition pruning based the 'dt' column value. If your table is partitioned by 'dt' column, the query would end up scanning entire table.
It is ideal to compute the required date value dynamically in a shell script if you are working against partitioned columns. If your version of Hive doesn't support variable substitution based on hiveconf, you can achieve the same as shown below
hive -e "SELECT .... FROM <table> where dt=$date_var;"
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: (Get the current date -1) in Hive
Date: Mon, 6 Aug 2012 23:26:46 +0000
In the case here it literally is taking the UNIX timestamp, formatting it in yyyy-mm-dd format and then subtracting the specified integer (in this case 1)
Sent from my Lumia 900
ext Techy Teck
8/6/2012 3:37 PM
Re: (Get the current date -1) in Hive
Thanks Carla for the suggestion, I am currently using Hive 0.6 and that Hive version doesn't supports variable substitution with hiveconf variable, so that is the reason I was looking for some other alternative-
So you are saying basically, If I add your suggestion in my query like below-
select * from lip_data_quality where dt = 'date_sub(FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd') , 1)';
Then the above query will be interpreted as like below-
select * from lip_data_quality where dt = '2012-08-05';
Am I right? And what does date_sub do here? I am not familiar with that.
Correct me if I am wrong.
On Mon, Aug 6, 2012 at 12:23 PM, <[EMAIL PROTECTED]> wrote:
If you are just using it in a query, you can do this:
date_sub(FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd') , 1)
I generally do my date calculations in a shell script and pass them in with a hiveconf variable.
From: ext Yue Guan [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 06, 2012 15:00
To: [EMAIL PROTECTED]
Subject: Re: (Get the current date -1) in Hive
guess you can use sub_date, but you have to get today by some outside script.
On 08/06/2012 02:10 PM, Techy Teck wrote:
> Is there any way to get the current date -1 in Hive means yesterdays
> date always?
Techy Teck 2012-08-07, 23:36