配置单元命令错误Expression Not In Group By Key product_id [英] hive command error Expression Not In Group By Key product_id

查看:2081
本文介绍了配置单元命令错误Expression Not In Group By Key product_id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用以下格式写成的HDFS表格A

 用户产品
U1 101
U1 102
U1 103
U2 101
U2 104
U3 102
code $ $ b $ p

...............

 描述A; 
>>用户字符串
产品int

现在如果我想汇总用户,用户分组在一起,我应该如何编写配置单元命令?

 从用户组中选择用户,产品; 

error:line 1:14 Expression Not In Group By Key product


解决方案

您可以在配置单元中使用 collect_set(col)函数按用户名汇总产品。



使用以下命令:

 从用户组中选择用户,collect_set(产品) 

您将获得如下输出:

  U1 [102,103,101] 
U2 [101,104]
U3 [102]

请参阅 Hive收集collect_set()的文档
获取更多信息。


I have a HDFS table A written in the following format

user  product
U1       101
U1       102
U1       103
U2       101
U2       104
U3       102

...............

describe A;
>> user   string
   product int

Now if I want to aggregate users so that products by the same user are grouped together, how should I write the hive command?

select user, product from A group by user;

error: line 1:14 Expression Not In Group By Key product

解决方案

You can use collect_set(col) function in hive for aggregating products by user name.

Use below command :

select user,collect_set(product) from A group by user;

You will get output like below :

U1      [102,103,101]
U2      [101,104]
U3      [102]

Please refer Hive Documentation for collect_set() for more information.

这篇关于配置单元命令错误Expression Not In Group By Key product_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆