check pushDownContext validation after withNewProbeExpression() (#34704) (#34737)

when the runtime filter target to a constant, the PushDownContext.finalTarget is null.
in this case, do not pushdown runtime filter.
example:
select * from (select 1 as x from T1) T2 join T3 on T2.x=T3.x
when push down RF(T3.x->T2.x) inside "select 1 as x from T1", the column x is a constant, and the pushDown stopped.

(cherry picked from commit 7f06cf0a0125d84c41e1edbb71366e293f70239d)
This commit is contained in:
minghong
2024-05-12 18:09:13 +08:00
committed by GitHub
parent 7a172a55ab
commit 755757e57c

View File

@ -103,9 +103,14 @@ public class RuntimeFilterPushDownVisitor extends PlanVisitor<Boolean, PushDownC
this.exprOrder = exprOrder;
this.isNot = isNot;
Expression expr = getSingleNumericSlotOrExpressionCoveredByCast(probeExpr);
/* finalTarget can be null if it is not a column from base table.
for example:
select * from T1 join (select 9 as x) T2 on T1.x=T2.x,
where the final target of T2.x is a constant
*/
if (expr instanceof Slot) {
probeSlot = (Slot) expr;
finalTarget = rfContext.getAliasTransferPair((Slot) probeSlot);
finalTarget = rfContext.getAliasTransferPair(probeSlot);
} else {
finalTarget = null;
probeSlot = null;
@ -289,6 +294,9 @@ public class RuntimeFilterPushDownVisitor extends PlanVisitor<Boolean, PushDownC
}
for (Expression prob : probExprList) {
PushDownContext ctxForChild = prob.equals(ctx.probeExpr) ? ctx : ctx.withNewProbeExpression(prob);
if (!ctxForChild.isValid()) {
continue;
}
if (ctx.rfContext.isRelationUseByPlan(leftNode, ctxForChild.finalTarget.first)) {
pushed |= leftNode.accept(this, ctxForChild);
}
@ -363,8 +371,11 @@ public class RuntimeFilterPushDownVisitor extends PlanVisitor<Boolean, PushDownC
}
}
}
return project.child().accept(this, ctxProjectProbeExpr);
if (!ctxProjectProbeExpr.isValid()) {
return false;
} else {
return project.child().accept(this, ctxProjectProbeExpr);
}
}
@Override
@ -401,7 +412,7 @@ public class RuntimeFilterPushDownVisitor extends PlanVisitor<Boolean, PushDownC
* +--->select 0, 0
* push down context for "select 0, 0" is invalid
*/
pushedDown |= setOperation.child(i).accept(this, ctx.withNewProbeExpression(newProbeExpr));
pushedDown |= setOperation.child(i).accept(this, childPushDownContext);
}
}
return pushedDown;