Skip to content

Commit

Permalink
[fix](nereids) runtime filter with probe expr should be pushed thoug…
Browse files Browse the repository at this point in the history
…h set operator #33010
  • Loading branch information
englefly authored Apr 3, 2024
1 parent d58c7a8 commit 343c0c1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.trees.plans.physical.PhysicalRelation;
import org.apache.doris.nereids.trees.plans.physical.PhysicalSetOperation;
import org.apache.doris.nereids.trees.plans.physical.PhysicalTopN;
import org.apache.doris.nereids.trees.plans.physical.PhysicalWindow;
import org.apache.doris.nereids.trees.plans.physical.RuntimeFilter;
Expand Down Expand Up @@ -497,6 +498,23 @@ public PhysicalRelation visitPhysicalRelation(PhysicalRelation relation, Cascade
return relation;
}

@Override
public PhysicalSetOperation visitPhysicalSetOperation(PhysicalSetOperation setOperation, CascadesContext context) {
setOperation.children().forEach(child -> child.accept(this, context));
RuntimeFilterContext ctx = context.getRuntimeFilterContext();
if (!setOperation.getRegularChildrenOutputs().isEmpty()) {
// example: RegularChildrenOutputs is empty
// "select 1 a, 2 b union all select 3, 4 union all select 10 e, 20 f;"
for (int i = 0; i < setOperation.getOutput().size(); i++) {
Pair childSlotPair = ctx.getAliasTransferPair(setOperation.getRegularChildOutput(0).get(0));
if (childSlotPair != null) {
ctx.aliasTransferMapPut(setOperation.getOutput().get(i), childSlotPair);
}
}
}
return setOperation;
}

// runtime filter build side ndv
private long getBuildSideNdv(AbstractPhysicalJoin<? extends Plan, ? extends Plan> join,
ComparisonPredicate compare) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@ PhysicalResultSink
--------------PhysicalProject
----------------PhysicalOlapScan[region]

-- !rf_setop_expr --
PhysicalResultSink
--hashAgg[GLOBAL]
----PhysicalDistribute[DistributionSpecGather]
------hashAgg[LOCAL]
--------PhysicalProject
----------hashJoin[INNER_JOIN] hashCondition=((expr_abs(l_linenumber) = expr_cast(r_regionkey as LARGEINT))) otherCondition=() build RFs:RF0 expr_cast(r_regionkey as LARGEINT)->[abs(l_linenumber),abs(o_orderkey)]
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalExcept
------------------PhysicalProject
--------------------hashAgg[GLOBAL]
----------------------PhysicalDistribute[DistributionSpecHash]
------------------------hashAgg[LOCAL]
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[lineitem] apply RFs: RF0
------------------PhysicalDistribute[DistributionSpecHash]
--------------------PhysicalProject
----------------------hashAgg[LOCAL]
------------------------PhysicalProject
--------------------------PhysicalOlapScan[orders] apply RFs: RF0
------------PhysicalDistribute[DistributionSpecHash]
--------------PhysicalProject
----------------PhysicalOlapScan[region]

Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ suite("test_pushdown_setop") {
sql 'set enable_nereids_timeout = false'
sql 'set enable_runtime_filter_prune=false'
sql 'set runtime_filter_type=8'
def query = """ select count() from ((select l_linenumber from lineitem) except (select o_orderkey from orders)) T join region on T.l_linenumber = r_regionkey;"""
qt_rf_setop """
explain shape plan
${query}
select count() from ((select l_linenumber from lineitem) except (select o_orderkey from orders)) T join region on T.l_linenumber = r_regionkey;
"""

qt_rf_setop_expr """
explain shape plan select count() from ((select l_linenumber from lineitem) except (select o_orderkey from orders)) T join region on abs(T.l_linenumber) = r_regionkey;
"""
}

0 comments on commit 343c0c1

Please sign in to comment.