为什么我在配置单元中执行分组时出错?
Why I am getting error while performing group by in hive?
我正在配置单元中执行以下命令:
Select child.data_volume_gprs_dl + child.data_volume_gprs_ul as data_usage,
parent.file_name,
parent.record_number
from table1 as parent
left join table2 child
on parent.file_name = child.file_name
and parent.record_number = child.record_number
where parent.served_imsi like '310120%'
or parent.served_imsi like '312530%'
and parent.serving_node_plmn_id like '310260%'
and parent.date_part = 20191201
group by parent.file_name, parent.record_number
Error: Error while compiling statement: FAILED: SemanticException
[Error 10025]: Line 1:7 Expression not in GROUP BY key
'data_volume_gprs_dl' (state=42000,code=10025)
为什么我会收到这个错误?
所有非聚合列都应在 GROUP BY
列表中,例如
group by parent.file_name, parent.record_number,
child.data_volume_gprs_dl, child.data_volume_gprs_ul
如果您只需要按 parent.file_name
和 parent.record_number
列进行分组,则可以应用聚合(sum()
、avg()
、count()
)函数对于其余的列。甚至添加 sum(child.data_volume_gprs_dl + child.data_volume_gprs_ul)
也是可能的。
我正在配置单元中执行以下命令:
Select child.data_volume_gprs_dl + child.data_volume_gprs_ul as data_usage,
parent.file_name,
parent.record_number
from table1 as parent
left join table2 child
on parent.file_name = child.file_name
and parent.record_number = child.record_number
where parent.served_imsi like '310120%'
or parent.served_imsi like '312530%'
and parent.serving_node_plmn_id like '310260%'
and parent.date_part = 20191201
group by parent.file_name, parent.record_number
Error: Error while compiling statement: FAILED: SemanticException [Error 10025]: Line 1:7 Expression not in GROUP BY key 'data_volume_gprs_dl' (state=42000,code=10025)
为什么我会收到这个错误?
所有非聚合列都应在 GROUP BY
列表中,例如
group by parent.file_name, parent.record_number,
child.data_volume_gprs_dl, child.data_volume_gprs_ul
如果您只需要按 parent.file_name
和 parent.record_number
列进行分组,则可以应用聚合(sum()
、avg()
、count()
)函数对于其余的列。甚至添加 sum(child.data_volume_gprs_dl + child.data_volume_gprs_ul)
也是可能的。