Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](nereids) runtime filter with probe expr should be pushed though set operator #33010

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
englefly marked this conversation as resolved.
Show resolved Hide resolved
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;
"""
}

Loading