Skip to content

Commit

Permalink
fix rf
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Sep 14, 2023
1 parent 268c867 commit 4f08aa7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,7 @@ public boolean pushDownRuntimeFilter(CascadesContext context, IdGenerator<Runtim
return false;
}

// TODO: if can't push down into join's chidren, try to
// find possible chance in upper layer
if (pushedDown) {
return true;
}

// in-filter is not friendly to pipeline
if (type == TRuntimeFilterType.IN_OR_BLOOM
&& ctx.getSessionVariable().getEnablePipelineEngine()
&& RuntimeFilterGenerator.hasRemoteTarget(this, scan)) {
type = TRuntimeFilterType.BLOOM;
}
RuntimeFilter filter = new RuntimeFilter(generator.getNextId(),
srcExpr, ImmutableList.of(olapScanSlot), type, exprOrder, this, buildSideNdv);
ctx.addJoinToTargetMap(this, olapScanSlot.getExprId());
ctx.setTargetExprIdToFilter(olapScanSlot.getExprId(), filter);
ctx.setTargetsOnScanNode(aliasTransferMap.get(probeSlot).first.getRelationId(), olapScanSlot);
return true;
return pushedDown;
}

private class ExprComparator implements Comparator<Expression> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@

package org.apache.doris.nereids.trees.plans.physical;

import org.apache.doris.common.IdGenerator;
import org.apache.doris.nereids.CascadesContext;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.properties.OrderKey;
import org.apache.doris.nereids.properties.PhysicalProperties;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.SortPhase;
import org.apache.doris.nereids.trees.plans.algebra.TopN;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.Utils;
import org.apache.doris.planner.RuntimeFilterId;
import org.apache.doris.statistics.Statistics;

import com.google.common.base.Preconditions;
import org.apache.doris.thrift.TRuntimeFilterType;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -169,4 +174,11 @@ public PhysicalTopN<Plan> resetLogicalProperties() {
null, physicalProperties, statistics, child());
}

public boolean pushDownRuntimeFilter(CascadesContext context, IdGenerator<RuntimeFilterId> generator,
AbstractPhysicalJoin<?, ?> builderNode,
Expression src, Expression probeExpr,
TRuntimeFilterType type, long buildSideNdv, int exprOrder) {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.doris.nereids.trees.plans.physical;

import org.apache.doris.common.IdGenerator;
import org.apache.doris.nereids.CascadesContext;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.properties.PhysicalProperties;
Expand All @@ -31,10 +33,12 @@
import org.apache.doris.nereids.trees.plans.algebra.Window;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.Utils;
import org.apache.doris.planner.RuntimeFilterId;
import org.apache.doris.statistics.Statistics;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import org.apache.doris.thrift.TRuntimeFilterType;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -188,4 +192,11 @@ public PhysicalWindow<CHILD_TYPE> resetLogicalProperties() {
return new PhysicalWindow<>(windowFrameGroup, requireProperties, windowExpressions, groupExpression,
null, physicalProperties, statistics, child());
}

public boolean pushDownRuntimeFilter(CascadesContext context, IdGenerator<RuntimeFilterId> generator,
AbstractPhysicalJoin<?, ?> builderNode,
Expression src, Expression probeExpr,
TRuntimeFilterType type, long buildSideNdv, int exprOrder) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,18 @@ private void checkRuntimeFilterExprs(List<RuntimeFilter> filters, List<Pair<Stri
filter.getTargetExprs().get(0).getName())));
}
}

@Test
public void testRuntimeFilterBlockByWindow() {
String sql = "SELECT * FROM (select rank() over(partition by lo_custkey), lo_custkey from lineorder) t JOIN customer on lo_custkey = c_custkey";
List<RuntimeFilter> filters = getRuntimeFilters(sql).get();
Assertions.assertEquals(0, filters.size());
}

@Test
public void testRuntimeFilterBlockByTopN() {
String sql = "SELECT * FROM (select lo_custkey from lineorder order by lo_custkey limit 10) t JOIN customer on lo_custkey = c_custkey";
List<RuntimeFilter> filters = getRuntimeFilters(sql).get();
Assertions.assertEquals(0, filters.size());
}
}
7 changes: 7 additions & 0 deletions post_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

cp -r fe/fe-core/target/generated-sources/annotations/* fe/fe-core/target/generated-sources
cp -r fe/fe-core/target/generated-sources/cup/* fe/fe-core/target/generated-sources
rm -rf fe/fe-core/target/generated-sources/cup/*
rm -rf fe/fe-core/target/generated-sources/annotations/*
cp output/fe/lib/help-resource.zip fe/target/classes/
cp output/fe/lib/help-resource.zip fe/fe-core/target/classes/

0 comments on commit 4f08aa7

Please sign in to comment.