我试图合并一堆表,其中一些字段的类型是bigint数组。当我试着在Hive中投射这些时,它不断地给我一个“表达式not in group by key‘field\u name’”。
我的代码如下:
CREATE TABLE sample_table stored AS avro AS
SELECT cast(cast(rand()* 1000000000000000000 AS BIGINT) AS string) id,
'PERSON'AS person,
name AS name,
age AS age,
gender AS gender
FROM table_a
UNION ALL
SELECT cast(cast(rand()* 1000000000000000000 AS BIGINT) AS string) id,
'PERSON'AS person,
name AS name,
collect_list(
CAST(NULL AS BIGINT)
) AS age,
null AS gender
FROM table_b
生成的错误如下:
sql错误[500051][hy000]:[cloudera]hivejdbcdriver处理查询/语句时出错。错误代码:10025,sql状态:tstatustatuscode:error_status,infomessages:[*org.apache.hive.service.cli.hivesqlexception:error while 编译语句:失败:semanticexception[error 10025]:行4:7表达式不在group by key“age”中:28:27,org.apache.hive.service.cli.operation。operation:tosqlexception:操作。java:400,org.apache.hive.service.cli.operation.sqloperation:prepare:sqloperation。java:187
1条答案
按热度按时间m3eecexj1#
collect_list
是聚合函数。你需要group by
每个非恒定场。