为什么这个Hive QL应按' ds'?进行分组?

时间:2014-04-17 08:30:06

标签: hive hiveql

select 
(floor(cast(ds as bigint)/100)) as date_time,
count(DISTINCT trans_id) as n_trans
from xxx
where ds >= "20140301" and adzone_id = '10263209'
group by 1;

Begin execute SQL: select 
(floor(cast(ds as bigint)/100)) as date_time,
count(DISTINCT trans_id) as n_trans
from xxx
where ds >= "20140301" and adzone_id = '10263209'
group by 1
Hive history file=/xxx.txt
FAILED: Error in semantic analysis: Line 0:-1 Expression not in GROUP BY key 'ds'
over

ds = yyyyMMdd且date_time为yyyymm(ds div 100和floor)。

我只是通过字段1(date_time)进行分组,但为什么编译说它应该按照' ds'?

分组

编辑:

ds是分区的字段。

1 个答案:

答案 0 :(得分:0)

Hive group by可以在原始列数据上完成