Home  >  Article  >  Database  >  Hive.GROUPINGSETS有BUG?

Hive.GROUPINGSETS有BUG?

WBOY
WBOYOriginal
2016-06-07 15:55:561770browse

随着Hive 0.10版的发布,GROUPING SETS出现了,并提供了ROLL UP和CUBE这两个特殊场景的子句,真是喜闻乐见的特性

随着Hive 0.10版的发布,GROUPING SETS出现了,并提供了ROLL UP和CUBE这两个特殊场景的子句,真是喜闻乐见的特性啊。
不过最近在写两个HQL查询脚本的时候,我发现,对表达式进行GROUP BY并用GROUPING SETS自定义这些表达式的分组方式时,GROUPING SETS好像会出现解析异常:
FAILED: ParseException line 66:14 missing ) at ',' near ')' in subquery source
line 66:80 mismatched input ',' expecting ) near ')' in subquery source
以下是GROUP子句的片段:
group by t1.my_month, t1.product, t1.usr_type, if(t3.earliest_logtime_monthly = '20140101', 'new_usr', 'old_usr'), if(t2.CTClass = 105, t1.ipcountry, t1.ipprovince), t1.ChannelID

grouping sets  ((t1.my_month, t1.usr_type, t1.ChannelID), (t1.my_month, t1.product, t1.usr_type, t1.ChannelID), (t1.my_month, if(t3.earliest_logtime_monthly = '20140101', 'new_usr', 'old_usr'), t1.ChannelID), (t1.my_month, t1.product, if(t3.earliest_logtime_monthly = '20140101', 'new_usr', 'old_usr'), t1.ChannelID), (t1.my_month, if(t2.Dim_CityClass = 105, t1.ipcountry, t1.ipprovince), t1.ChannelID), (t1.my_month, t1.product, if(t2.CTClass = 105, t1.ipcountry, t1.ipprovince), t1.ChannelID))
去掉GROUPING SETS子句后脚本就正常,而且看了半天也没看出来GROUPING SETS子句里这样的组合方式有什么逻辑错误。
理论上,表达式和字段应该一样,可以出现在GROUPING SETS子句里并进行任意组合,对一些表达式的实测结果也表明GROUPING SETS里确实是支持表达式的。

这样的情况,使我怀疑GROUPING SETS子句的括号匹配逻辑没做得很完善,导致了括号配对抛出异常。不过,具体的问题,还是需要通过研究一下Hive实现源码来进一步确定这到底是不是一个BUG。

--------------------------------------------------------------------------------------------------------------------

2014-04-28

今天发现,好像是限定性名称的原因呢!就和Java的switch...case的case子句一样,case子句里的枚举值不能用限定性名称(EnumType.EnumValue1),只能用非限定性名称(EnumValue1)!难道grouping sets的Java实现涉及到switch...case子句?有待研究。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn