我在 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'
我想在单个查询中进行全部操作。
最佳答案
如果您的目标是只找出每个 acct_id 组的最大 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
关于database - Hive 中 collect_list(column) 的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38896525/