seawinde commented on code in PR #27568:
URL: https://github.com/apache/doris/pull/27568#discussion_r1413246092


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PredicatesSplitter.java:
##########
@@ -0,0 +1,111 @@
+// 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.exploration.mv;
+
+import org.apache.doris.nereids.trees.expressions.Alias;
+import org.apache.doris.nereids.trees.expressions.Cast;
+import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
+import org.apache.doris.nereids.trees.expressions.CompoundPredicate;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.expressions.Or;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import 
org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionVisitor;
+import org.apache.doris.nereids.util.ExpressionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Split the expression to equal, range and residual predicate.
+ * Should instance when used.
+ * TODO support complex predicate split
+ */
+public class PredicatesSplitter {
+
+    private List<Expression> equalPredicates = new ArrayList<>();
+    private List<Expression> rangePredicates = new ArrayList<>();
+    private List<Expression> residualPredicates = new ArrayList<>();
+    private List<Expression> conjunctExpressions;
+
+    private final PredicateExtract instance = new PredicateExtract();
+
+    public PredicatesSplitter(Expression target) {
+        this.conjunctExpressions = ExpressionUtils.extractConjunction(target);
+        for (Expression expression : conjunctExpressions) {
+            expression.accept(instance, expression);
+        }
+    }
+
+    /**PredicateExtract*/
+    public class PredicateExtract extends DefaultExpressionVisitor<Void, 
Expression> {
+
+        @Override
+        public Void visitComparisonPredicate(ComparisonPredicate 
comparisonPredicate, Expression sourceExpression) {
+            Expression leftArg = comparisonPredicate.getArgument(0);
+            Expression rightArg = comparisonPredicate.getArgument(1);
+            boolean leftArgOnlyContainsColumnRef = 
containOnlyColumnRef(leftArg, true);
+            boolean rightArgOnlyContainsColumnRef = 
containOnlyColumnRef(rightArg, true);
+            if (comparisonPredicate instanceof EqualTo || comparisonPredicate 
instanceof NullSafeEqual) {
+                if (leftArgOnlyContainsColumnRef && 
rightArgOnlyContainsColumnRef) {
+                    equalPredicates.add(comparisonPredicate);
+                    return null;
+                } else {
+                    residualPredicates.add(comparisonPredicate);
+                }
+            } else if ((leftArgOnlyContainsColumnRef && rightArg instanceof 
Literal)
+                    || (rightArgOnlyContainsColumnRef && leftArg instanceof 
Literal)) {
+                rangePredicates.add(comparisonPredicate);
+            } else {
+                residualPredicates.add(comparisonPredicate);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitCompoundPredicate(CompoundPredicate 
compoundPredicate, Expression context) {
+            if (compoundPredicate instanceof Or) {
+                residualPredicates.add(compoundPredicate);
+                return null;
+            }
+            return super.visitCompoundPredicate(compoundPredicate, context);

Review Comment:
   The class extend from DefaultExpressionVisitor, the DefaultExpressionVisitor 
implement the visit children method.
   So I change call to `super.visit(compoundPredicate, context)`



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PredicatesSplitter.java:
##########
@@ -0,0 +1,111 @@
+// 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.exploration.mv;
+
+import org.apache.doris.nereids.trees.expressions.Alias;
+import org.apache.doris.nereids.trees.expressions.Cast;
+import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
+import org.apache.doris.nereids.trees.expressions.CompoundPredicate;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.expressions.Or;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import 
org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionVisitor;
+import org.apache.doris.nereids.util.ExpressionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Split the expression to equal, range and residual predicate.
+ * Should instance when used.
+ * TODO support complex predicate split
+ */
+public class PredicatesSplitter {
+
+    private List<Expression> equalPredicates = new ArrayList<>();
+    private List<Expression> rangePredicates = new ArrayList<>();
+    private List<Expression> residualPredicates = new ArrayList<>();
+    private List<Expression> conjunctExpressions;
+
+    private final PredicateExtract instance = new PredicateExtract();
+
+    public PredicatesSplitter(Expression target) {
+        this.conjunctExpressions = ExpressionUtils.extractConjunction(target);
+        for (Expression expression : conjunctExpressions) {
+            expression.accept(instance, expression);
+        }
+    }
+
+    /**PredicateExtract*/
+    public class PredicateExtract extends DefaultExpressionVisitor<Void, 
Expression> {
+
+        @Override
+        public Void visitComparisonPredicate(ComparisonPredicate 
comparisonPredicate, Expression sourceExpression) {
+            Expression leftArg = comparisonPredicate.getArgument(0);
+            Expression rightArg = comparisonPredicate.getArgument(1);
+            boolean leftArgOnlyContainsColumnRef = 
containOnlyColumnRef(leftArg, true);
+            boolean rightArgOnlyContainsColumnRef = 
containOnlyColumnRef(rightArg, true);
+            if (comparisonPredicate instanceof EqualTo || comparisonPredicate 
instanceof NullSafeEqual) {
+                if (leftArgOnlyContainsColumnRef && 
rightArgOnlyContainsColumnRef) {
+                    equalPredicates.add(comparisonPredicate);
+                    return null;

Review Comment:
   have fixed it



-- 
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-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to