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

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

问题描述

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

  id bigint,rank bigint,日期字符串

我想每月获得avg(等级)。我可以使用这个命令。

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

但是,我也想获取日期信息。我使用这个命令:

 从lensrank_archive中选择a.lens_id,avg(a.rank),a.date_saved 
由a.lens_id,year(a.date_saved),month(a.date_saved)组成的
组;

它抱怨:表达式不在组中按键

解决方案

完整的错误信息应该是格式表达式不在组中按键[值]

[value] 会告诉您 Group By中需要的表达式



只要看看两个查询,我就会说你需要添加 a.date_saved 明确地指向 Group By


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);

It complains: Expression Not In Group By Key

解决方案

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.

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天全站免登陆