Impala: 所有 DISTINCT 聚合函数需要有相同的参数集
Impala: all DISTINCT aggregate functions need to have the same set of parameters
我的 Impala 查询中出现以下错误:
select
upload_key,
max(my_timestamp) as upload_time,
max(color_key) as max_color_fk,
count(distinct color_key) as color_count,
count(distinct id) as toy_count
from upload_table
group by upload_key
得到错误:
AnalysisException: all DISTINCT aggregate functions need to have the
same set of parameters as count(DISTINCT color_key); deviating
function: count(DISTINCT id)
我不确定为什么会出现此错误。我所做的是针对每个组(按 upload_key
分组),我试图计算有多少 distinct id
以及有多少 distinct color_key
。
有人知道吗
错误消息表明 DISTINCT
仅允许在一个 列 [组合] 上,但您尝试两个,color_key
& id
.解决方法是先选择两个 Select,然后再连接:
select
t1.upload_key,
t1.upload_time,
t1.max_color_fk,
t1.color_count,
t2.toy_count
from
(
select
upload_key,
max(my_timestamp) as upload_time,
max(color_key) as max_color_fk,
count(distinct color_key) as color_count
from upload_table
group by upload_key
) as t1
join
(
select
upload_key
count(distinct id) as toy_count
from upload_table
group by upload_key
) as t2
on t1. upload_key = t2.upload_key
我的 Impala 查询中出现以下错误:
select
upload_key,
max(my_timestamp) as upload_time,
max(color_key) as max_color_fk,
count(distinct color_key) as color_count,
count(distinct id) as toy_count
from upload_table
group by upload_key
得到错误:
AnalysisException: all DISTINCT aggregate functions need to have the same set of parameters as count(DISTINCT color_key); deviating function: count(DISTINCT id)
我不确定为什么会出现此错误。我所做的是针对每个组(按 upload_key
分组),我试图计算有多少 distinct id
以及有多少 distinct color_key
。
有人知道吗
错误消息表明 DISTINCT
仅允许在一个 列 [组合] 上,但您尝试两个,color_key
& id
.解决方法是先选择两个 Select,然后再连接:
select
t1.upload_key,
t1.upload_time,
t1.max_color_fk,
t1.color_count,
t2.toy_count
from
(
select
upload_key,
max(my_timestamp) as upload_time,
max(color_key) as max_color_fk,
count(distinct color_key) as color_count
from upload_table
group by upload_key
) as t1
join
(
select
upload_key
count(distinct id) as toy_count
from upload_table
group by upload_key
) as t2
on t1. upload_key = t2.upload_key