Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix](nereids)make agg output unchanged after normalized repeat (apac…
…he#36207) The NormalizeRepeat rule can change the output of agg. For example: ```sql SELECT col_int_undef_signed2 AS C1 , col_int_undef_signed2 FROM normalize_repeat_name_unchanged GROUP BY GROUPING SETS ( (col_int_undef_signed2), (col_int_undef_signed2)) ``` Before fixing the bug, the plan is: ```sql LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] ) +--LogicalProject[94] ( distinct=false, projects=[C1#7, C1#7], excepts=[] ) +--LogicalAggregate[93] ( groupByExpr=[C1#7, GROUPING_ID#8], outputExpr=[C1#7, GROUPING_ID#8], hasRepeat=true ) +--LogicalRepeat ( groupingSets=[[C1#7], [C1#7]], outputExpressions=[C1#7, GROUPING_ID#8] ) +--LogicalProject[91] ( distinct=false, projects=[col_int_undef_signed2#1 AS `C1`apache#7], excepts=[] ) +--LogicalOlapScan ( ) ``` This can lead to column not found in LogicalResultSink, report error: Input slot(s) not in childs output: col_int_undef_signed2#1 in plan: LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] ) child output is: [C1#7] This pr makes agg output unchanged after normalized repeat. After fixing, the plan is: ```sql LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] ) +--LogicalProject[94] ( distinct=false, projects=[C1#7, C1#7 as `col_int_undef_signed2`#1], excepts=[] ) +--LogicalAggregate[93] ( groupByExpr=[C1#7, GROUPING_ID#8], outputExpr=[C1#7, GROUPING_ID#8], hasRepeat=true ) +--LogicalRepeat ( groupingSets=[[C1#7], [C1#7]], outputExpressions=[C1#7, GROUPING_ID#8] ) +--LogicalProject[91] ( distinct=false, projects=[col_int_undef_signed2#1 AS `C1`apache#7], excepts=[] ) +--LogicalOlapScan ( ) ``` --------- Co-authored-by: feiniaofeiafei <[email protected]>
- Loading branch information