HIVE 中Grouping sets 相关的问题

hive 中使用grouping SETS时遇见对坑

:hive报错

Grouping sets aggregations (with rollups or cubes) are not allowed if aggregation function parameters overlap with the aggregation functions columns

select p.city_name,p.rent_type,p.sf_type,p.sign_type

,sum(case when rent_type= '合租' then 1 else 2 end ) as rooms

from rooms

group by p.city_name,p.rent_type,p.sf_type,p.sign_type
grouping SETS(
p.city_name,
(p.city_name,p.rent_type),
(p.city_name,p.sf_type),
(p.city_name,p.sign_type),
(p.city_name,p.rent_type,p.sf_type),
(p.city_name,p.rent_type,p.sign_type),
(p.city_name,p.sf_type,p.sign_type),
(p.city_name,p.rent_type,p.sf_type,p.sign_type)
))b

在调试过程中 有些 平台是支持对比如 pyspark

sum(case when rent_type= '合租' then 1 else 2 end ) as rooms
rent_type 为分组字段
但在hive服务器有时候不支持

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容