hive 表达式不在按键分组 [英] hive Expression Not In Group By Key

查看:30
本文介绍了hive 表达式不在按键分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 HIVE 中创建了一个表.它有以下列:

I create a table in HIVE. It has the following columns:

id bigint, rank bigint, date string

我想每月获得平均(排名).我可以使用这个命令.它有效.

I want to get avg(rank) per month. I can use this command. It works.

select a.lens_id, avg(a.rank)
from tableA a
group by a.lens_id, year(a.date_saved), month(a.date_saved); 

不过,我也想获取日期信息.我使用这个命令:

However, I also want to get date information. I use this command:

select a.lens_id, avg(a.rank), a.date_saved
from lensrank_archive a
group by a.lens_id, year(a.date_saved), month(a.date_saved);

它抱怨:Expression Not In Group By Key

推荐答案

完整的错误信息的格式应该是 Expression Not In Group By Key [value].
[value] 会告诉您 Group By 中需要什么表达式.

The full error message should be in the format Expression Not In Group By Key [value].
The [value] will tell you what expression needs to be in the Group By.

仅看这两个查询,我会说您需要将 a.date_saved 显式添加到 Group By.

Just looking at the two queries, I'd say that you need to add a.date_saved explicitly to the Group By.

这篇关于hive 表达式不在按键分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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