This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new f908ea5573 [fix](Nereids) union distinct should not prune any column (#21610) f908ea5573 is described below commit f908ea55732c86ff8055bee785c46e1655128945 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Fri Jul 7 14:38:28 2023 +0800 [fix](Nereids) union distinct should not prune any column (#21610) --- .../java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java | 5 +++++ regression-test/data/nereids_syntax_p0/set_operation.out | 3 +++ regression-test/suites/nereids_syntax_p0/set_operation.groovy | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java index ff50074df3..7f3205d8f2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java @@ -24,6 +24,7 @@ import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.algebra.Aggregate; +import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier; import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate; import org.apache.doris.nereids.trees.plans.logical.LogicalCTEProducer; import org.apache.doris.nereids.trees.plans.logical.LogicalExcept; @@ -111,6 +112,10 @@ public class ColumnPruning extends DefaultPlanRewriter<PruneContext> implements // union can not prune children by the common logic, we must override visit method to write special code. @Override public Plan visitLogicalUnion(LogicalUnion union, PruneContext context) { + if (union.getQualifier() == Qualifier.DISTINCT) { + return skipPruneThisAndFirstLevelChildren(union); + } + LogicalUnion prunedOutputUnion = pruneOutput(union, union.getOutputs(), union::pruneOutputs, context); // start prune children of union diff --git a/regression-test/data/nereids_syntax_p0/set_operation.out b/regression-test/data/nereids_syntax_p0/set_operation.out index 8f8db3a540..1fa3a8ebee 100644 --- a/regression-test/data/nereids_syntax_p0/set_operation.out +++ b/regression-test/data/nereids_syntax_p0/set_operation.out @@ -589,3 +589,6 @@ hell0 2020-05-25 2020-05-25 00 +-- !union45 -- +2 + diff --git a/regression-test/suites/nereids_syntax_p0/set_operation.groovy b/regression-test/suites/nereids_syntax_p0/set_operation.groovy index 94baeb47f3..58cc456bc1 100644 --- a/regression-test/suites/nereids_syntax_p0/set_operation.groovy +++ b/regression-test/suites/nereids_syntax_p0/set_operation.groovy @@ -285,4 +285,9 @@ suite("test_nereids_set_operation") { ) a order by 1 """ + + // test union distinct column prune + qt_union45 """ + select count(*) from (select 1, 2 union select 1,1 ) a; + """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org