Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The exception will be reprodued by the following sql when using Hive Dialect:
create table t(category int, live int, comments int) SELECT grouping(category), lag(live) over(partition by grouping(category)) FROM t GROUP BY category, live;
The reson is it will first call `HiveParserCalcitePlanner#genSelectForWindowing` to generate the window, which will then call `HiveParserUtils#rewriteGroupingFunctionAST` to rewrite the group function in the over window :
// rewrite grouping function if (current.getType() == HiveASTParser.TOK_FUNCTION && current.getChildCount() >= 2) { HiveParserASTNode func = (HiveParserASTNode) current.getChild(0); if (func.getText().equals("grouping")) { visited.setValue(true); convertGrouping( current, grpByAstExprs, noneSet, legacyGrouping, found); } }
So `grouping(category)` will be converted to `grouping(0, 1)`.
After `HiveParserCalcitePlanner#genSelectForWindowing`, it will try to rewrite it again:
if (!qbp.getDestToGroupBy().isEmpty()) { // Special handling of grouping function expr = rewriteGroupingFunctionAST( getGroupByForClause(qbp, selClauseName), expr, !cubeRollupGrpSetPresent); }
And it will also fall back to `convertGrouping` again as `current.getChildCount() >= 2` will be true. But then, it can't find any field
presented in group by for it's `grouping(0, 1)` now.
Attachments
Attachments
Issue Links
- links to