[fix](nereids) removeRuntimeFilter() removes more than one RFs if there are different types of RF from the buildNode to the target (#31197)
this bug can be produced on tpcds 95, when set runtime filter type: min-max + bloom
This commit is contained in:
@ -181,12 +181,12 @@ public class RuntimeFilterContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* remove rf from builderNode to target
|
||||
* remove the given target from runtime filters from builderNode to target with all runtime filter types
|
||||
*
|
||||
* @param targetId rf target
|
||||
* @param builderNode rf src
|
||||
*/
|
||||
public void removeFilter(ExprId targetId, PhysicalHashJoin builderNode) {
|
||||
public void removeFilters(ExprId targetId, PhysicalHashJoin builderNode) {
|
||||
List<RuntimeFilter> filters = targetExprIdToFilter.get(targetId);
|
||||
if (filters != null) {
|
||||
Iterator<RuntimeFilter> filterIter = filters.iterator();
|
||||
@ -219,6 +219,33 @@ public class RuntimeFilterContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove one target from rf, and if there is no target, remove the rf
|
||||
*/
|
||||
public void removeFilter(RuntimeFilter rf, ExprId targetId) {
|
||||
Iterator<Slot> targetSlotIter = rf.getTargetSlots().listIterator();
|
||||
Iterator<PhysicalRelation> targetScanIter = rf.getTargetScans().iterator();
|
||||
Iterator<Expression> targetExpressionIter = rf.getTargetExpressions().iterator();
|
||||
Slot targetSlot;
|
||||
PhysicalRelation targetScan;
|
||||
while (targetScanIter.hasNext() && targetSlotIter.hasNext() && targetExpressionIter.hasNext()) {
|
||||
targetExpressionIter.next();
|
||||
targetScan = targetScanIter.next();
|
||||
targetSlot = targetSlotIter.next();
|
||||
if (targetSlot.getExprId().equals(targetId)) {
|
||||
targetScan.removeAppliedRuntimeFilter(rf);
|
||||
targetExpressionIter.remove();
|
||||
targetScanIter.remove();
|
||||
targetSlotIter.remove();
|
||||
}
|
||||
}
|
||||
if (rf.getTargetSlots().isEmpty()) {
|
||||
rf.getBuilderNode().getRuntimeFilters().remove(rf);
|
||||
targetExprIdToFilter.get(targetId).remove(rf);
|
||||
prunedRF.add(rf);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTargetsOnScanNode(PhysicalRelation relation, Slot slot) {
|
||||
this.targetOnOlapScanNodeMap.computeIfAbsent(relation, k -> Lists.newArrayList()).add(slot);
|
||||
}
|
||||
|
||||
@ -224,8 +224,8 @@ public class RuntimeFilterGenerator extends PlanPostProcessor {
|
||||
);
|
||||
if (pushedDown) {
|
||||
rfCtx.removeFilter(
|
||||
rightDeepTargetExpressionOnCTE.getInputSlotExprIds().iterator().next(),
|
||||
(PhysicalHashJoin) rfToPush.getBuilderNode());
|
||||
rfToPush,
|
||||
rightDeepTargetExpressionOnCTE.getInputSlotExprIds().iterator().next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class RuntimeFilterPruner extends PlanPostProcessor {
|
||||
outputExprIdOfExpandTargets.addAll(expand.target2.getOutputExprIds());
|
||||
rfContext.getTargetExprIdByFilterJoin(join)
|
||||
.stream().filter(exprId -> outputExprIdOfExpandTargets.contains(exprId))
|
||||
.forEach(exprId -> rfContext.removeFilter(exprId, join));
|
||||
.forEach(exprId -> rfContext.removeFilters(exprId, join));
|
||||
}
|
||||
}
|
||||
RuntimeFilterContext.EffectiveSrcType childType =
|
||||
@ -163,7 +163,7 @@ public class RuntimeFilterPruner extends PlanPostProcessor {
|
||||
}
|
||||
}
|
||||
if (!isEffective) {
|
||||
exprIds.stream().forEach(exprId -> rfContext.removeFilter(exprId, join));
|
||||
exprIds.stream().forEach(exprId -> rfContext.removeFilters(exprId, join));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class RuntimeFilterPrunerForExternalTable extends PlanPostProcessor {
|
||||
for (int i = 0; i < rf.getTargetScans().size(); i++) {
|
||||
PhysicalRelation scan = rf.getTargetScans().get(i);
|
||||
if (canPrune(scan, joinAncestors)) {
|
||||
rfCtx.removeFilter(rf.getTargetSlots().get(i).getExprId(), (PhysicalHashJoin) join);
|
||||
rfCtx.removeFilters(rf.getTargetSlots().get(i).getExprId(), (PhysicalHashJoin) join);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user