This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 33fad043415 [opt](Nereids) use 1 instead narrowest column when do column pruning (#41548) (#41627) 33fad043415 is described below commit 33fad04341500ec80e2b88341741a31a768646f3 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Thu Oct 10 14:02:23 2024 +0800 [opt](Nereids) use 1 instead narrowest column when do column pruning (#41548) (#41627) pick from master #41548 --- be/src/pipeline/exec/table_function_operator.cpp | 3 -- .../trees/plans/logical/LogicalProject.java | 3 +- .../doris/nereids/jobs/joinorder/TPCHTest.java | 4 +-- .../nereids/rules/rewrite/ColumnPruningTest.java | 15 ++++----- .../runtime_filter/test_pushdown_setop.out | 38 ---------------------- .../suites/nereids_syntax_p0/agg_with_const.groovy | 2 +- 6 files changed, 12 insertions(+), 53 deletions(-) diff --git a/be/src/pipeline/exec/table_function_operator.cpp b/be/src/pipeline/exec/table_function_operator.cpp index 54b5646d1ab..8b16cb8dce1 100644 --- a/be/src/pipeline/exec/table_function_operator.cpp +++ b/be/src/pipeline/exec/table_function_operator.cpp @@ -241,9 +241,6 @@ TableFunctionOperatorX::TableFunctionOperatorX(ObjectPool* pool, const TPlanNode Status TableFunctionOperatorX::_prepare_output_slot_ids(const TPlanNode& tnode) { // Prepare output slot ids - if (tnode.table_function_node.outputSlotIds.empty()) { - return Status::InternalError("Output slots of table function node is empty"); - } SlotId max_id = -1; for (auto slot_id : tnode.table_function_node.outputSlotIds) { if (slot_id > max_id) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java index 4174d625936..0a384912598 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java @@ -29,6 +29,7 @@ import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.functions.scalar.Uuid; +import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; import org.apache.doris.nereids.trees.plans.algebra.Project; @@ -93,7 +94,7 @@ public class LogicalProject<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_ Preconditions.checkArgument(!projects.isEmpty() || !(child instanceof Unbound), "projects can not be empty when child plan is unbound"); this.projects = projects.isEmpty() - ? ImmutableList.of(ExpressionUtils.selectMinimumColumn(child.get(0).getOutput())) + ? ImmutableList.of(new Alias(new TinyIntLiteral((byte) 1))) : projects; this.excepts = Utils.fastToImmutableList(excepts); this.isDistinct = isDistinct; diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java index 9eefe62ea82..12f16058bea 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java @@ -68,8 +68,8 @@ public class TPCHTest extends TPCHTestBase implements MemoPatternMatchSupported logicalAggregate( logicalProject().when( project -> project.getProjects().size() == 1 - && project.getProjects().get(0) instanceof SlotReference - && "o_orderdate".equals(project.getProjects().get(0).toSql())))) + && !(project.getProjects().get(0) instanceof SlotReference) + ))) ); } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ColumnPruningTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ColumnPruningTest.java index e6f2bb6838d..9f18eeb851f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ColumnPruningTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/ColumnPruningTest.java @@ -18,10 +18,11 @@ package org.apache.doris.nereids.rules.rewrite; import org.apache.doris.nereids.trees.expressions.NamedExpression; +import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.logical.LogicalProject; import org.apache.doris.nereids.types.DoubleType; -import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.TinyIntType; import org.apache.doris.nereids.util.MemoPatternMatchSupported; import org.apache.doris.nereids.util.PlanChecker; import org.apache.doris.utframe.TestWithFeService; @@ -188,7 +189,7 @@ public class ColumnPruningTest extends TestWithFeService implements MemoPatternM logicalAggregate( logicalProject( logicalOlapScan() - ).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE) + ).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE) && p.getProjects().size() == 1) ) ); @@ -203,7 +204,7 @@ public class ColumnPruningTest extends TestWithFeService implements MemoPatternM logicalAggregate( logicalProject( logicalOlapScan() - ).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE) + ).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE) && p.getProjects().size() == 1) ) ); @@ -218,7 +219,7 @@ public class ColumnPruningTest extends TestWithFeService implements MemoPatternM logicalAggregate( logicalProject( logicalOlapScan() - ).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE) + ).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE) && p.getProjects().size() == 1) ) ); @@ -233,7 +234,7 @@ public class ColumnPruningTest extends TestWithFeService implements MemoPatternM logicalAggregate( logicalProject( logicalOlapScan() - ).when(p -> p.getProjects().get(0).getDataType().equals(IntegerType.INSTANCE) + ).when(p -> p.getProjects().get(0).getDataType().equals(TinyIntType.INSTANCE) && p.getProjects().size() == 1) ) ); @@ -283,9 +284,7 @@ public class ColumnPruningTest extends TestWithFeService implements MemoPatternM "internal.test.student.id", "internal.test.student.name"))), logicalProject(logicalRelation()) - .when(p -> getOutputQualifiedNames(p) - .containsAll(ImmutableList.of( - "internal.test.score.sid"))) + .when(p -> p.getProjects().stream().noneMatch(SlotReference.class::isInstance)) ) ) ); diff --git a/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out b/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out deleted file mode 100644 index aeca755c29b..00000000000 --- a/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out +++ /dev/null @@ -1,38 +0,0 @@ --- This file is automatically generated. You should know what you did if you want to edit this --- !rf_setop -- -PhysicalResultSink ---hashAgg[GLOBAL] -----PhysicalDistribute[DistributionSpecGather] -------hashAgg[LOCAL] ---------PhysicalProject -----------hashJoin[INNER_JOIN] hashCondition=((T.l_linenumber = expr_cast(r_regionkey as BIGINT))) otherCondition=() build RFs:RF0 expr_cast(r_regionkey as BIGINT)->[cast(l_linenumber as BIGINT),o_orderkey] -------------PhysicalExcept ---------------PhysicalDistribute[DistributionSpecHash] -----------------PhysicalProject -------------------PhysicalOlapScan[lineitem] apply RFs: RF0 ---------------PhysicalDistribute[DistributionSpecHash] -----------------PhysicalProject -------------------PhysicalOlapScan[orders] apply RFs: RF0 -------------PhysicalDistribute[DistributionSpecHash] ---------------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(cast(l_linenumber as BIGINT)),abs(o_orderkey)] -------------PhysicalProject ---------------PhysicalExcept -----------------PhysicalDistribute[DistributionSpecHash] -------------------PhysicalProject ---------------------PhysicalOlapScan[lineitem] apply RFs: RF0 -----------------PhysicalDistribute[DistributionSpecHash] -------------------PhysicalProject ---------------------PhysicalOlapScan[orders] apply RFs: RF0 -------------PhysicalDistribute[DistributionSpecReplicated] ---------------PhysicalProject -----------------PhysicalOlapScan[region] - diff --git a/regression-test/suites/nereids_syntax_p0/agg_with_const.groovy b/regression-test/suites/nereids_syntax_p0/agg_with_const.groovy index 375517ab6a6..00865dbcbde 100644 --- a/regression-test/suites/nereids_syntax_p0/agg_with_const.groovy +++ b/regression-test/suites/nereids_syntax_p0/agg_with_const.groovy @@ -51,7 +51,7 @@ suite("agg_with_const") { explain { sql """select count(*) from ( select distinct col1 as a0, null as a1, null as a2 from agg_with_const_tbl)t""" - contains "projections: NULL" + contains "projections: col1" } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org