【问题标题】:SemanticException [Error 10128]: Not yet supported place for UDAF 'sum' in Hive/HueSemanticException [错误 10128]:尚不支持 Hive/Hue 中 UDAF 'sum' 的位置
【发布时间】:2017-10-26 17:53:56
【问题描述】:

来自这句话:

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'

还有其他方法可以选择数据的总和吗?

【问题讨论】:

    标签: hive hadoop-yarn hiveql hue


    【解决方案1】:

    您需要在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
    

    【讨论】:

      猜你喜欢
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多