Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix](nereids) fix normalize repeat alias rewrite (apache#38166)
Induced by apache#34196. In NormalizeRepeat, when NormalizeToSlot is called, aggregate function parameters, grouping scalar function parameters, and all expressions in grouping sets (including columns and column aliases) are pushed down to the lower-level project output. In the previous PR apache#34196, the context was split into two, but the two contexts were not consistent. It is possible that the triplets in one context save (id, c1, id as c1), and the triplets in the other context save (id, id, id). This causes id as c1 to be pushed down, but there is a reference to id in the upper-level LogicalRepeat, which causes the slot to be not found. This pr has been modified. If the same slot in the projection column has different aliases, for example, select id as c1, id, id as c3, grouping(id) from table1 group by grouping sets((id, value2),(id)); then id as c1 (using the first alias) will be pushed down to the project. In both the LogicalRepeat operator and the LogicalAggregate operator, c1 is referenced as the input slot, and id and c3 will not be used as input slots. before NormalizeRepeat: LogicalResultSink[32] ( outputExprs=[c1#3, id#0, c3#4, __grouping_3#5] ) +--LogicalRepeat ( groupingSets=[[id#0, value2#2], [id#0]], outputExpressions=[id#0 AS `c1`#3, id#0, id#0 AS `c3`#4, Grouping(id#0) AS `Grouping(id)`#5] ) +--LogicalOlapScan (qualified=table1) After NormalizeRepeat: LogicalResultSink[33] (outputExprs=[c1#3, id#0, c3#4, __grouping_3#5]) +--LogicalAggregate[30] (groupByExpr=[c1#3, value2#2, GROUPING_ID#7, GROUPING_PREFIX_c1#6 originExpression=Grouping(c1#3)], outputExpr=[c1#3, c1#3 AS `id`#0, c1#3 AS `c3`#4, GROUPING_PREFIX_c1#6 originExpression=Grouping(c1#3) AS `GROUPING_PREFIX_c1`#5], hasRepeat=true ) +--LogicalRepeat (groupingSets=[[c1#3, value2#2], [c1#3]], outputExpressions=[c1#3, value2#2, GROUPING_ID#7, GROUPING_PREFIX_c1#6 originExpression=Grouping(c1#3)] ) +--LogicalProject[28] (projects=[id#0 AS `c1`#3, value2#2]) +--LogicalOlapScan (qualified=table1)
- Loading branch information