[fix](Nereids) filter-limit-project translate to wrong plan (#32496)

This commit is contained in:
morrySnow
2024-03-22 10:35:43 +08:00
committed by yiguolei
parent b2db5a4ded
commit 01a5413e45
3 changed files with 74 additions and 1 deletions

View File

@ -1170,7 +1170,14 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
}
PlanNode planNode = inputFragment.getPlanRoot();
if (planNode instanceof ExchangeNode || planNode instanceof SortNode || planNode instanceof UnionNode) {
Plan child = filter.child();
while (child instanceof PhysicalLimit) {
child = ((PhysicalLimit<?>) child).child();
}
if (planNode instanceof ExchangeNode || planNode instanceof SortNode || planNode instanceof UnionNode
// this means we have filter->limit->project, need a SelectNode
|| (child instanceof PhysicalProject
&& !((PhysicalProject<?>) child).hasPushedDownToProjectionFunctions())) {
// the three nodes don't support conjuncts, need create a SelectNode to filter data
SelectNode selectNode = new SelectNode(context.nextPlanNodeId(), planNode);
selectNode.setNereidsId(filter.getId());