hive: 按列分组计算

3lxsmp7m  于 2021-04-02  发布在  Hive
关注(0)|答案(1)|浏览(510)

我需要执行如下查询

select 
myUsualField, SOME_FUNCTION(myAnotherField) as myUnusualField 
from MYTABLE
group by 
myUsualField, myUnusualField

在hive中,这个查询失败了:在表中的其他字段中找不到字段myunusualfield。
这是否意味着为了在hive中用任何计算列进行分组,我必须使用子查询?

select * from (
    select 
    myUsualField, SOME_FUNCTION(myAnotherField) as myUnusualField 
    from MYTABLE
) sourceTable
    group by 
    myUsualField, myUnusualField
6rqinv9w

6rqinv9w1#

select myUsualField, SOME_FUNCTION(myAnotherField) as myUnusualField 
from MYTABLE
group by myUsualField, SOME_FUNCTION(myAnotherField) ;

相关问题