[fix](nereids) cannot generate RF on colocate join and prune useful RF in RF prune (#14234)

1. when we translate colocated join, we lost RF information attached to the right child, and hence BE will not generate those RFs.
2. when a RF is useless, we prune all RFs on the scan node by mistake
This commit is contained in:
minghong
2022-11-14 16:36:55 +08:00
committed by GitHub
parent 8dd2f8b349
commit bea66e6a12
2 changed files with 12 additions and 3 deletions

View File

@ -1088,6 +1088,8 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
hashJoinNode.setChild(0, leftFragment.getPlanRoot());
hashJoinNode.setChild(1, rightFragment.getPlanRoot());
leftFragment.setPlanRoot(hashJoinNode);
rightFragment.getTargetRuntimeFilterIds().stream().forEach(leftFragment::setTargetRuntimeFilterIds);
rightFragment.getBuilderRuntimeFilterIds().stream().forEach(leftFragment::setBuilderRuntimeFilterIds);
context.removePlanFragment(rightFragment);
leftFragment.setHasColocatePlanNode(true);
return leftFragment;

View File

@ -130,9 +130,16 @@ public class RuntimeFilterPruner extends PlanPostProcessor {
@Override
public PhysicalOlapScan visitPhysicalOlapScan(PhysicalOlapScan olapScan, CascadesContext context) {
List<Slot> slots = context.getRuntimeFilterContext().getTargetOnOlapScanNodeMap().get(olapScan.getId());
if (slots != null && !slots.isEmpty()) {
context.getRuntimeFilterContext().addEffectiveSrcNode(olapScan);
RuntimeFilterContext rfCtx = context.getRuntimeFilterContext();
List<Slot> slots = rfCtx.getTargetOnOlapScanNodeMap().get(olapScan.getId());
if (slots != null) {
for (Slot slot : slots) {
//if this scan node is the target of any effective RF, it is effective source
if (!rfCtx.getTargetExprIdToFilter().get(slot.getExprId()).isEmpty()) {
context.getRuntimeFilterContext().addEffectiveSrcNode(olapScan);
break;
}
}
}
return olapScan;
}