You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2023/01/04 03:42:46 UTC
[GitHub] [doris] zhengshiJ opened a new pull request, #15591: [Feature] (Nereids) support un equals conjuncts in un scalar sub query
zhengshiJ opened a new pull request, #15591:
URL: https://github.com/apache/doris/pull/15591
# Proposed changes
Issue Number: close #xxx
## Problem summary
support un equals conjuncts in un scalar sub query.
[fix] in correlated subquery wrong result
## Checklist(Required)
1. Does it affect the original behavior:
- [ ] Yes
- [ ] No
- [ ] I don't know
2. Has unit tests been added:
- [ ] Yes
- [ ] No
- [ ] No Need
3. Has document been added or modified:
- [ ] Yes
- [ ] No
- [ ] No Need
4. Does it need to update dependencies:
- [ ] Yes
- [ ] No
5. Are there any changes that cannot be rolled back:
- [ ] Yes (If Yes, please explain WHY)
- [ ] No
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] hello-stephen commented on pull request #15591: [Feature] (Nereids) support un equals conjuncts in un scalar sub query
Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #15591:
URL: https://github.com/apache/doris/pull/15591#issuecomment-1370485432
TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 36.02 seconds
load time: 651 seconds
storage size: 17122925806 Bytes
https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230104045125_clickbench_pr_73197.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] 924060929 commented on a diff in pull request #15591: [Feature] (Nereids) support un equals conjuncts in un scalar sub query
Posted by GitBox <gi...@apache.org>.
924060929 commented on code in PR #15591:
URL: https://github.com/apache/doris/pull/15591#discussion_r1061280978
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/EliminateFilterUnderApplyProject.java:
##########
@@ -0,0 +1,97 @@
+// 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.logical;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.rules.rewrite.OneRewriteRuleFactory;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.GroupPlan;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalApply;
+import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+import org.apache.doris.nereids.util.ExpressionUtils;
+import org.apache.doris.nereids.util.PlanUtils;
+import org.apache.doris.nereids.util.Utils;
+
+import com.google.common.collect.ImmutableSet;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Adjust the order of Project and apply in correlated subqueries.
+ *
+ * before:
+ * apply
+ * / \
+ * Input(output:b) Project(output:a)
+ * |
+ * Filter(Correlated predicate/UnCorrelated predicate)
+ * |
+ * child
+ *
+ * after:
+ * apply(Correlated predicate)
+ * / \
+ * Input(output:b) Project(output:a)
+ * |
+ * Filter(UnCorrelated predicate)
+ * |
+ * child
+ */
+public class EliminateFilterUnderApplyProject extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalApply(group(), logicalProject(logicalFilter()))
+ .when(LogicalApply::isCorrelated)
+ .when(LogicalApply::isIn)
+ .then(apply -> {
+ LogicalProject<LogicalFilter<GroupPlan>> project = apply.right();
+ LogicalFilter<GroupPlan> filter = project.child();
+ Set<Expression> conjuncts = filter.getConjuncts();
+ Map<Boolean, List<Expression>> split = Utils.splitCorrelatedConjuncts(
+ conjuncts, apply.getCorrelationSlot());
+ List<Expression> correlatedPredicate = split.get(true);
+ List<Expression> unCorrelatedPredicate = split.get(false);
+
+ // the representative has experienced the rule and added the correlated predicate to the apply node
+ if (correlatedPredicate.isEmpty()) {
+ return apply;
+ }
+
+ Plan child = PlanUtils.filterOrSelf(ImmutableSet.copyOf(unCorrelatedPredicate), filter.child());
+ List<NamedExpression> projects = new ArrayList<>();
+ projects.addAll(project.getProjects());
+ ExpressionUtils.collect(correlatedPredicate, SlotReference.class::isInstance).stream()
+ .filter(e -> filter.child().getOutput().contains(e))
+ .filter(e -> !projects.contains(e))
+ .map(NamedExpression.class::cast)
+ .forEach(projects::add);
+ LogicalProject newProject = new LogicalProject(projects, child);
Review Comment:
You can use `Set<NamedExpression>`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] 924060929 merged pull request #15591: [Feature] (Nereids) support un equals conjuncts in un scalar sub query
Posted by GitBox <gi...@apache.org>.
924060929 merged PR #15591:
URL: https://github.com/apache/doris/pull/15591
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org