semanticexception[error 10128]:还不支持将udaf'sum'放在hive/hue中

t1rydlwq  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(1496)

从这句话中:

SELECT a.comunity, sum(b.cont_woman),sum(b.cont_men)

FROM cont_per_comunity.states_per_comunities a

JOIN cont_per_comunity.cont_per_state b

ON a.state = b.state

WHERE sum(b.cont_woman) >= sum(b.cont_men)

GROUP BY a.comunity;

我得到以下错误:

Error occurred executing hive query: Error while compiling statement: FAILED: SemanticException [Error 10128]: Line 9:6 Not yet supported place for UDAF 'sum'

有没有其他方法来选择数据的总和?

yshpjwxd

yshpjwxd1#

你需要在一段时间内做到这一点 having 子句,或在外部查询中。不能像您正在尝试的那样在where子句中使用聚合函数。
试试这个:

SELECT a.comunity, sum(b.cont_woman),sum(b.cont_men)
FROM cont_per_comunity.states_per_comunities a
JOIN cont_per_comunity.cont_per_state b
ON a.state = b.state
GROUP BY a.comunity
having sum(b.cont_woman) >= sum(b.cont_men)

或者

select * from (
    SELECT a.comunity, sum(b.cont_woman) as cont_woman
    ,sum(b.cont_men) as cont_men
    FROM cont_per_comunity.states_per_comunities a
    JOIN cont_per_comunity.cont_per_state b
    ON a.state = b.state
    GROUP BY a.comunity ) t
    where cont_woman >= cont_men

相关问题