This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 5d665713746 [fix](Nereids) add push down filter through logical generate (#28212) 5d665713746 is described below commit 5d66571374699a29324a6fdfbf2f9b4ed80f68e5 Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Thu Dec 14 15:40:35 2023 +0800 [fix](Nereids) add push down filter through logical generate (#28212) --- .../org/apache/doris/nereids/rules/RuleSet.java | 2 + .../org/apache/doris/nereids/rules/RuleType.java | 1 + .../rewrite/PushdownFilterThroughGenerate.java | 45 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java index 0ae8c0e3ddd..dfb00b08b84 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java @@ -82,6 +82,7 @@ import org.apache.doris.nereids.rules.rewrite.MergeProjects; import org.apache.doris.nereids.rules.rewrite.PushdownAliasThroughJoin; import org.apache.doris.nereids.rules.rewrite.PushdownExpressionsInHashCondition; import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughAggregation; +import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughGenerate; import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughJoin; import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughPartitionTopN; import org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughProject; @@ -126,6 +127,7 @@ public class RuleSet { new PushdownFilterThroughProject(), new PushdownFilterThroughSort(), new PushdownJoinOtherCondition(), + new PushdownFilterThroughGenerate(), new PushdownFilterThroughJoin(), new PushdownExpressionsInHashCondition(), new PushdownFilterThroughAggregation(), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java index dd6a4374a6d..ec8d53de8f0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java @@ -144,6 +144,7 @@ public enum RuleType { PUSHDOWN_PREDICATE_THROUGH_REPEAT(RuleTypeClass.REWRITE), PUSHDOWN_EXPRESSIONS_IN_HASH_CONDITIONS(RuleTypeClass.REWRITE), // Pushdown filter + PUSH_DOWN_FILTER_THROUGH_GENERATE(RuleTypeClass.REWRITE), PUSHDOWN_FILTER_THROUGH_JOIN(RuleTypeClass.REWRITE), PUSHDOWN_FILTER_THROUGH_LEFT_SEMI_JOIN(RuleTypeClass.REWRITE), PUSH_FILTER_INSIDE_JOIN(RuleTypeClass.REWRITE), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownFilterThroughGenerate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownFilterThroughGenerate.java new file mode 100644 index 00000000000..bae21640a42 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownFilterThroughGenerate.java @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.rules.rewrite; + +import org.apache.doris.nereids.rules.Rule; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.logical.LogicalGenerate; + +/** + * Push the predicate down through generate. + */ +public class PushdownFilterThroughGenerate extends OneRewriteRuleFactory { + public static final PushdownFilterThroughGenerate INSTANCE = new PushdownFilterThroughGenerate(); + + /** + * filter-generate to generate->filter + */ + @Override + public Rule build() { + return logicalFilter(logicalGenerate()).then(filter -> { + LogicalGenerate<Plan> generate = filter.child(); + if (generate.child().getOutputSet().containsAll(filter.getInputSlots())) { + return generate.withChildren(filter.withChildren(generate.children())); + } else { + return null; + } + }).toRule(RuleType.PUSH_DOWN_FILTER_THROUGH_GENERATE); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org