【问题标题】:Max value of collect_list(column) in HiveHive 中 collect_list(column) 的最大值
【发布时间】:2016-08-11 12:33:14
【问题描述】:

我在 Hive 中使用以下命令。并得到正确的结果。

select acct_id,collect_list(expr_dt) from experiences
    > group by acct_id;

输出:

900      ["2015-03-31"]
707       ["2015-03-31","2014-12-10"]
903       ["2015-03-31"]
-435       ["2015-03-31"]
718       ["2015-03-31","2014-06-03"]

我想获取每个帐户的最长日期。

当我尝试执行以下查询时出现错误。

select acct_id,max(collect_list(expr_dt)) from experiences
    > group by acct_id;

错误是 -

SemanticException [Error 10128]: Line 1:19 Not yet supported place for UDAF 'collect_list'

我想在单个查询中进行全部操作。

【问题讨论】:

    标签: database hadoop hive


    【解决方案1】:

    如果您的目标是仅找出每个 acct_id 组的 max expr_dt,则可以不使用 collect_list 使用 max

    输入:

    hive> select * from  experiences;
    OK
    900 2015-03-31
    707 2015-03-31
    707 2014-12-10
    903 2015-03-31
    -435 2015-03-31
    718 2015-03-31
    718 2014-06-03
    

    查询:

    hive> select acct_id,max(expr_dt) from experiences group by acct_id;
    

    输出:

    Total MapReduce CPU Time Spent: 4 seconds 30 msec
    OK
    -435    2015-03-31
    707 2015-03-31
    718 2015-03-31
    900 2015-03-31
    903 2015-03-31
    

    【讨论】:

      猜你喜欢
      • 2015-09-28
      • 2017-12-17
      • 1970-01-01
      • 2012-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      相关资源
      最近更新 更多