【发布时间】:2021-05-07 01:51:22
【问题描述】:
我试图在一个查询中获得累积总和。它在 SQL、PRESTO 等中运行良好,但在 HIVE 中却不行,这会引发错误消息。
create table test(store varchar(10), item int, quantity int)
insert into test
select 'depot',101,1
union select 'depot',101,2
union select 'depot',101,5
union select 'depot',102,1
union select 'depot',102,3
| store | item | revenue |
|---|---|---|
| depot | 101 | 1 |
| depot | 101 | 2 |
| depot | 101 | 5 |
| depot | 102 | 1 |
| depot | 102 | 3 |
select store, item,
sum(sum(revenue)) over (partition by store order by item)
from test
group by store, item
预期输出:
| store | item | quantity |
|---|---|---|
| depot | 101 | 8 |
| depot | 102 | 12 |
错误:
[代码:40000,SQL 状态:42000] 编译语句时出错: 失败:SemanticException 无法将窗口调用分解为 团体。至少 1 个组必须仅依赖于输入列。还要检查 对于循环依赖。潜在错误: org.apache.hadoop.hive.ql.parse.SemanticException:第 1:24 行 表达式不在 GROUP BY 键“收入”中
有什么建议吗?
【问题讨论】:
标签: hive hiveql hive-query