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 

但在hive服务器有时候不支持

此时问题应该是 分组字段不应该出现在聚合条件里 ,所以再子数据里先处理roos 就好

你可能感兴趣的:(数据仓库,hive,大数据)