[fix](planner)use tupleId of agg node to get its unsigned conjuncts (#21949)

This commit is contained in:
starocean999
2023-07-19 00:46:49 +08:00
committed by GitHub
parent beec0e9169
commit fff1983f40
3 changed files with 11 additions and 1 deletions

View File

@ -2420,7 +2420,8 @@ public class Analyzer {
// constant conjuncts should be push down to all leaf node except agg node.
// (see getPredicatesBoundedByGroupbysSourceExpr method)
// so we need remove constant conjuncts when expr is not a leaf node.
List<Expr> unassigned = getUnassignedConjuncts(node.getTblRefIds());
List<Expr> unassigned = getUnassignedConjuncts(
node instanceof AggregationNode ? node.getTupleIds() : node.getTblRefIds());
if (!node.getChildren().isEmpty() && !(node instanceof AggregationNode)) {
unassigned = unassigned.stream()
.filter(e -> !e.isConstant()).collect(Collectors.toList());

View File

@ -2,3 +2,9 @@
-- !select1 --
1 2
-- !select2 --
1 2
-- !select3 --
1 2

View File

@ -19,4 +19,7 @@
sql "SET enable_nereids_planner=true"
sql "SET enable_fallback_to_original_planner=false"
qt_select1 'select * from (select 1 as a, 2 as b union all select 3, 3) t where a = 1;'
sql "SET enable_nereids_planner=false"
qt_select2 'select * from (select 1 as a, 2 as b union all select 3, 3) t where a = 1;'
qt_select3 'select * from (select 1 as a, 2 as b union select 3, 3) t where a = 1;'
}