当我编写蜂巢查询时,如下所示
select count(*)
from order
where order_month >= '2016-11';阶段的Hadoop作业信息-1:映射器数量: 5;减速器数量:1
我只得到5个映射器,这意味着只读取所需的分区(2016-11和2016-12)。
与我使用函数编写的查询相同
select count(*)
from order
where order_month >= concat(year(DATE_SUB(to_date(from_unixtime(UNIX_TIMESTAMP())),10)),'-',month(DATE_SUB(to_date(from_unixtime(UNIX_TIMESTAMP())),10)));注:
concat(year(DATE_SUB(to_date(from_unixtime(UNIX_TIMESTAMP())),10)),'-',month(DATE_SUB(to_date(from_unixtime(UNIX_TIMESTAMP())),10))) = '2016-11‘
阶段的Hadoop作业信息-1:映射器数量: 216;减速器数量:1
这一次,它正在读取所有分区{即2004-10到2016-12}。。
如何修改查询以只读取所需的分区。
发布于 2020-02-12 06:57:18
unix_timestamp()函数是不确定的,并且妨碍了对查询的适当优化--从2.0开始就不再支持CURRENT_TIMESTAMP和CURRENT_DATE了。
使用current_date,也不需要分别计算年份和月份:
where order_month >= substr(date_sub(current_date, 10),1,7)https://stackoverflow.com/questions/41077242
复制相似问题