你如何获得'活动日期>当前日期 - 10天)在HiveQL? [英] How do you get 'event date > current date - 10 days) in HiveQL?
问题描述
我正在访问的表有一个' xxdatetime'列中添加了unix时间戳和'eventdate'列,日期为yyyy-mm-dd。
在Impala中,答案很简单:
where eventdate> to_date(days_sub(now(),10))
我在Hive中使用了它的一个变体,因为我猜它正在扫描整个表格并且表格是MASSIVE:
where datediff(cast(current_timestamp()as string) ,eventdate = 10
Hive SQL中有一种轻量级方式来过滤xxdatetime或eventdate列'date-10 days'?
Eventdate是我的索引列,date_sub是(字符串,减去的天数)和current_date是目前的Hive yyyy mm dd。
eventdate> date_sub(current_date,5)
我不确定这是不是超轻量,但它的工作原理!
I'm putting together a query that will get refreshed daily that needs to pull records from the last ten dates.
The tables I'm accessing have a 'xxdatetime' column with the unix time stamp and an 'eventdate' column with the date in a yyyy-mm-dd.
In Impala, the answer was easy:
where eventdate > to_date(days_sub(now(), 10))
I used a variation of it in Hive that failed because I guess it was scanning the whole table and the tables are MASSIVE:
where datediff(cast(current_timestamp() as string), eventdate)=10
Is there a light weight way in Hive SQL to filter the xxdatetime or eventdate columns by 'today - 10 days'?
Eventdate is my indexed column, date_sub is (string, days to subtract) and current_date is the current Hive yyyy mm dd.
eventdate > date_sub(current_date, 5)
I'm not sure if this is super light weight but it works!
这篇关于你如何获得'活动日期>当前日期 - 10天)在HiveQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!