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 2021/12/10 08:49:19 UTC

[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #7357: [feature] (planner) InferPredicate (#7096)

EmmyMiao87 commented on a change in pull request #7357:
URL: https://github.com/apache/incubator-doris/pull/7357#discussion_r766479415



##########
File path: fe/fe-core/src/main/java/org/apache/doris/rewrite/InferFiltersRule.java
##########
@@ -0,0 +1,302 @@
+// 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.rewrite;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.BinaryPredicate;
+import org.apache.doris.analysis.CompoundPredicate;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.IsNullPredicate;
+import org.apache.doris.analysis.JoinOperator;
+import org.apache.doris.analysis.LiteralExpr;
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+
+import com.google.common.collect.Sets;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * The function of this rule is to derive a new predicate based on the current predicate.
+ * eg.
+ * t1.id = t2.id and t2.id = t3.id and t3.id = 100;
+ * -->
+ * t1.id = 100 and t2.id = 100 and t3.id = 100;
+ *
+ * 1. Register a new rule InferFiltersRule and add it to GlobalState.
+ * 2. Traverse Conjunct to construct on/where equivalence connection, numerical connection and isNullPredicate.
+ * 3. Use Warshall to infer all equivalence connections
+ * 4. Construct additional numerical connections and isNullPredicate
+ */
+public class InferFiltersRule implements ExprRewriteRule {
+    private final static Logger LOG = LogManager.getLogger(InferFiltersRule.class);
+    public static InferFiltersRule INSTANCE = new InferFiltersRule();
+
+    @Override
+    public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        if (expr == null) {
+            return null;
+        } else if (!analyzer.enableInferPredicate()) {
+            return expr;
+        } else {
+            ArrayList<Expr> slotEqSlotPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> slotToLiteralPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> newPredicatesList = new ArrayList<>();
+            ArrayList<Expr> isNullPredicatesList = new ArrayList<>();
+            Set<Expr> isNullPredicatesSet = Sets.newHashSet();
+
+            initAllStructure(expr, slotEqSlotPredicatesList, slotEqSlotPredicatesSet,
+                    slotToLiteralPredicatesList, slotToLiteralPredicatesSet,
+                    isNullPredicatesList, isNullPredicatesSet);
+
+            inferSlotPredicates(slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    slotToLiteralPredicatesList, newPredicatesList, analyzer);
+
+            inferIsNullPredicates(slotEqSlotPredicatesList, isNullPredicatesList,
+                    isNullPredicatesSet, newPredicatesList, analyzer);
+            
+            if (!newPredicatesList.isEmpty()) {
+                Expr rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, expr, newPredicatesList.get(0));
+                for (int index = 1; index < newPredicatesList.size(); index++) {
+                    rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, rewriteExpr, newPredicatesList.get(index));
+                }
+                return rewriteExpr;
+            }
+        }
+        return expr;
+    }
+
+    private void initAllStructure(Expr conjunct,
+                                  ArrayList<Expr> slotEqSlotPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet,
+                                  ArrayList<Expr> slotToLiteralPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                  ArrayList<Expr> isNullPredicatesList,
+                                  Set<Expr> isNullPredicatesSet) {
+        if (conjunct instanceof CompoundPredicate) {
+            for (int index = 0; index < conjunct.getChildren().size(); ++index) {
+                initAllStructure(conjunct.getChild(index), slotEqSlotPredicatesList,
+                        slotEqSlotPredicatesSet, slotToLiteralPredicatesList,
+                        slotToLiteralPredicatesSet, isNullPredicatesList, isNullPredicatesSet);
+            }
+        }
+        if (conjunct instanceof BinaryPredicate) {
+            Pair<Expr, Expr> pair = new Pair<>(conjunct.getChild(0), conjunct.getChild(1));
+            Pair<Expr, Expr> eqPair = new Pair<>(conjunct.getChild(1), conjunct.getChild(0));
+            if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof LiteralExpr) {
+                if (!slotToLiteralPredicatesSet.contains(pair)
+                    && !slotToLiteralPredicatesSet.contains(eqPair)) {
+                    slotToLiteralPredicatesSet.add(pair);
+                    slotToLiteralPredicatesList.add(conjunct);
+                }
+            } else if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof SlotRef) {
+                if (!slotEqSlotPredicatesSet.contains(pair)
+                    && !slotEqSlotPredicatesSet.contains(eqPair)) {
+                    slotEqSlotPredicatesSet.add(pair);
+                    slotEqSlotPredicatesList.add(conjunct);
+                }
+            }
+        } else if (conjunct instanceof IsNullPredicate) {
+            if (!isNullPredicatesSet.contains(conjunct.getChild(0))) {
+                isNullPredicatesSet.add(conjunct.getChild(0));
+                isNullPredicatesList.add(conjunct);
+            }
+        }
+    }
+
+    private void inferSlotPredicates(ArrayList<Expr> slotEqSlotPredicatesList,
+                                    Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                    ArrayList<Expr> slotToLiteralPredicatesList,
+                                    ArrayList<Expr> newPredicatesList,
+                                    Analyzer analyzer) {
+        ArrayList<Expr> tmpSlotToLiteralPredicatesList = new ArrayList<>();
+        for (Expr slotToLiteral : slotToLiteralPredicatesList) {
+            buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+        }
+
+        int tmpSize = 0;
+        do {
+            int startSize = tmpSlotToLiteralPredicatesList.size();
+
+            for (int index = 0; index < tmpSlotToLiteralPredicatesList.size(); ++index) {
+                Expr slotToLiteral = tmpSlotToLiteralPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            for (int index = 0; index < newPredicatesList.size(); ++index) {
+                Expr slotToLiteral = newPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            int endSize = tmpSlotToLiteralPredicatesList.size();
+            tmpSize = endSize - startSize;
+
+        } while (tmpSize != 0);

Review comment:
       If there is no new tmp predicate but new predicate, could new predicate infer the new tmp predicate.
   My suggestion is following:
   Do not distinguish between tmp and new predicate in the process, just as a mark.
   Just don't bring tmp when constructing a new expr at the end.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/rewrite/InferFiltersRule.java
##########
@@ -0,0 +1,302 @@
+// 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.rewrite;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.BinaryPredicate;
+import org.apache.doris.analysis.CompoundPredicate;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.IsNullPredicate;
+import org.apache.doris.analysis.JoinOperator;
+import org.apache.doris.analysis.LiteralExpr;
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+
+import com.google.common.collect.Sets;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * The function of this rule is to derive a new predicate based on the current predicate.
+ * eg.
+ * t1.id = t2.id and t2.id = t3.id and t3.id = 100;
+ * -->
+ * t1.id = 100 and t2.id = 100 and t3.id = 100;
+ *
+ * 1. Register a new rule InferFiltersRule and add it to GlobalState.
+ * 2. Traverse Conjunct to construct on/where equivalence connection, numerical connection and isNullPredicate.
+ * 3. Use Warshall to infer all equivalence connections
+ * 4. Construct additional numerical connections and isNullPredicate
+ */
+public class InferFiltersRule implements ExprRewriteRule {
+    private final static Logger LOG = LogManager.getLogger(InferFiltersRule.class);
+    public static InferFiltersRule INSTANCE = new InferFiltersRule();
+
+    @Override
+    public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        if (expr == null) {
+            return null;
+        } else if (!analyzer.enableInferPredicate()) {
+            return expr;
+        } else {
+            ArrayList<Expr> slotEqSlotPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> slotToLiteralPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> newPredicatesList = new ArrayList<>();
+            ArrayList<Expr> isNullPredicatesList = new ArrayList<>();
+            Set<Expr> isNullPredicatesSet = Sets.newHashSet();
+
+            initAllStructure(expr, slotEqSlotPredicatesList, slotEqSlotPredicatesSet,
+                    slotToLiteralPredicatesList, slotToLiteralPredicatesSet,
+                    isNullPredicatesList, isNullPredicatesSet);
+
+            inferSlotPredicates(slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    slotToLiteralPredicatesList, newPredicatesList, analyzer);
+
+            inferIsNullPredicates(slotEqSlotPredicatesList, isNullPredicatesList,
+                    isNullPredicatesSet, newPredicatesList, analyzer);
+            
+            if (!newPredicatesList.isEmpty()) {
+                Expr rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, expr, newPredicatesList.get(0));
+                for (int index = 1; index < newPredicatesList.size(); index++) {
+                    rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, rewriteExpr, newPredicatesList.get(index));
+                }
+                return rewriteExpr;
+            }
+        }
+        return expr;
+    }
+
+    private void initAllStructure(Expr conjunct,
+                                  ArrayList<Expr> slotEqSlotPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet,
+                                  ArrayList<Expr> slotToLiteralPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                  ArrayList<Expr> isNullPredicatesList,
+                                  Set<Expr> isNullPredicatesSet) {
+        if (conjunct instanceof CompoundPredicate) {
+            for (int index = 0; index < conjunct.getChildren().size(); ++index) {
+                initAllStructure(conjunct.getChild(index), slotEqSlotPredicatesList,
+                        slotEqSlotPredicatesSet, slotToLiteralPredicatesList,
+                        slotToLiteralPredicatesSet, isNullPredicatesList, isNullPredicatesSet);
+            }
+        }
+        if (conjunct instanceof BinaryPredicate) {
+            Pair<Expr, Expr> pair = new Pair<>(conjunct.getChild(0), conjunct.getChild(1));
+            Pair<Expr, Expr> eqPair = new Pair<>(conjunct.getChild(1), conjunct.getChild(0));
+            if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof LiteralExpr) {
+                if (!slotToLiteralPredicatesSet.contains(pair)
+                    && !slotToLiteralPredicatesSet.contains(eqPair)) {
+                    slotToLiteralPredicatesSet.add(pair);
+                    slotToLiteralPredicatesList.add(conjunct);
+                }
+            } else if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof SlotRef) {
+                if (!slotEqSlotPredicatesSet.contains(pair)
+                    && !slotEqSlotPredicatesSet.contains(eqPair)) {
+                    slotEqSlotPredicatesSet.add(pair);
+                    slotEqSlotPredicatesList.add(conjunct);
+                }
+            }
+        } else if (conjunct instanceof IsNullPredicate) {
+            if (!isNullPredicatesSet.contains(conjunct.getChild(0))) {
+                isNullPredicatesSet.add(conjunct.getChild(0));
+                isNullPredicatesList.add(conjunct);
+            }
+        }
+    }
+
+    private void inferSlotPredicates(ArrayList<Expr> slotEqSlotPredicatesList,
+                                    Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                    ArrayList<Expr> slotToLiteralPredicatesList,
+                                    ArrayList<Expr> newPredicatesList,
+                                    Analyzer analyzer) {
+        ArrayList<Expr> tmpSlotToLiteralPredicatesList = new ArrayList<>();
+        for (Expr slotToLiteral : slotToLiteralPredicatesList) {
+            buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+        }
+
+        int tmpSize = 0;
+        do {
+            int startSize = tmpSlotToLiteralPredicatesList.size();
+
+            for (int index = 0; index < tmpSlotToLiteralPredicatesList.size(); ++index) {
+                Expr slotToLiteral = tmpSlotToLiteralPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            for (int index = 0; index < newPredicatesList.size(); ++index) {
+                Expr slotToLiteral = newPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            int endSize = tmpSlotToLiteralPredicatesList.size();
+            tmpSize = endSize - startSize;
+
+        } while (tmpSize != 0);
+    }
+
+    private void buildNewBinaryPredicate(Expr slotToLiteral,
+                                         ArrayList<Expr> slotEqSlotPredicatesList,
+                                         Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                         ArrayList<Expr> newPredicatesList,
+                                         ArrayList<Expr> tmpSlotToLiteralPredicatesList,
+                                         Analyzer analyzer) {
+        SlotRef checkSlot = slotToLiteral.getChild(0).unwrapSlotRef();
+        for (Expr conjunct : slotEqSlotPredicatesList) {
+            SlotRef leftSlot = conjunct.getChild(0).unwrapSlotRef();
+            SlotRef rightSlot = conjunct.getChild(1).unwrapSlotRef();
+
+            if (checkSlot.simple_equals(leftSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, rightSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, rightSlot));
+            } else if (checkSlot.simple_equals(rightSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, leftSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, leftSlot));
+            }
+        }
+    }
+
+    private boolean isNeedInfer(SlotRef checkSlot, SlotRef newSlot) {
+        JoinOperator jop = newSlot.getDesc().getParent().getRef().getJoinOp();
+        boolean ret = false;
+        if (jop == null) {
+            JoinOperator checkJop = checkSlot.getDesc().getParent().getRef().getJoinOp();
+            if (checkJop.isInnerJoin()
+                    || checkJop == JoinOperator.RIGHT_SEMI_JOIN) {
+                ret = true;
+            } else if (checkJop == JoinOperator.RIGHT_OUTER_JOIN
+                    || checkJop == JoinOperator.RIGHT_ANTI_JOIN) {
+                ret = true;
+            }
+        } else if (jop.isInnerJoin()
+                || jop == JoinOperator.LEFT_SEMI_JOIN) {
+            ret = true;
+        } else if (jop == JoinOperator.LEFT_OUTER_JOIN
+                || jop == JoinOperator.LEFT_ANTI_JOIN) {
+            ret = true;
+        }
+        return ret;
+    }
+
+    private Expr genNewBinaryPredicate(Analyzer analyzer, Expr oldExpr, Expr newSlot) {
+        if (oldExpr instanceof BinaryPredicate) {
+            BinaryPredicate oldBP = (BinaryPredicate) oldExpr;
+            BinaryPredicate newBP = new BinaryPredicate(oldBP.getOp(), newSlot, oldBP.getChild(1));
+            newBP.analyzeNoThrow(analyzer);

Review comment:
       No need to analyze here

##########
File path: fe/fe-core/src/main/java/org/apache/doris/rewrite/InferFiltersRule.java
##########
@@ -0,0 +1,302 @@
+// 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.rewrite;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.BinaryPredicate;
+import org.apache.doris.analysis.CompoundPredicate;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.IsNullPredicate;
+import org.apache.doris.analysis.JoinOperator;
+import org.apache.doris.analysis.LiteralExpr;
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+
+import com.google.common.collect.Sets;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * The function of this rule is to derive a new predicate based on the current predicate.
+ * eg.
+ * t1.id = t2.id and t2.id = t3.id and t3.id = 100;
+ * -->
+ * t1.id = 100 and t2.id = 100 and t3.id = 100;
+ *
+ * 1. Register a new rule InferFiltersRule and add it to GlobalState.
+ * 2. Traverse Conjunct to construct on/where equivalence connection, numerical connection and isNullPredicate.
+ * 3. Use Warshall to infer all equivalence connections
+ * 4. Construct additional numerical connections and isNullPredicate
+ */
+public class InferFiltersRule implements ExprRewriteRule {
+    private final static Logger LOG = LogManager.getLogger(InferFiltersRule.class);
+    public static InferFiltersRule INSTANCE = new InferFiltersRule();
+
+    @Override
+    public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        if (expr == null) {
+            return null;
+        } else if (!analyzer.enableInferPredicate()) {
+            return expr;
+        } else {
+            ArrayList<Expr> slotEqSlotPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> slotToLiteralPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> newPredicatesList = new ArrayList<>();
+            ArrayList<Expr> isNullPredicatesList = new ArrayList<>();
+            Set<Expr> isNullPredicatesSet = Sets.newHashSet();
+
+            initAllStructure(expr, slotEqSlotPredicatesList, slotEqSlotPredicatesSet,
+                    slotToLiteralPredicatesList, slotToLiteralPredicatesSet,
+                    isNullPredicatesList, isNullPredicatesSet);
+
+            inferSlotPredicates(slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    slotToLiteralPredicatesList, newPredicatesList, analyzer);
+
+            inferIsNullPredicates(slotEqSlotPredicatesList, isNullPredicatesList,
+                    isNullPredicatesSet, newPredicatesList, analyzer);
+            
+            if (!newPredicatesList.isEmpty()) {
+                Expr rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, expr, newPredicatesList.get(0));
+                for (int index = 1; index < newPredicatesList.size(); index++) {
+                    rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, rewriteExpr, newPredicatesList.get(index));
+                }
+                return rewriteExpr;
+            }
+        }
+        return expr;
+    }
+
+    private void initAllStructure(Expr conjunct,
+                                  ArrayList<Expr> slotEqSlotPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet,
+                                  ArrayList<Expr> slotToLiteralPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                  ArrayList<Expr> isNullPredicatesList,
+                                  Set<Expr> isNullPredicatesSet) {
+        if (conjunct instanceof CompoundPredicate) {
+            for (int index = 0; index < conjunct.getChildren().size(); ++index) {
+                initAllStructure(conjunct.getChild(index), slotEqSlotPredicatesList,
+                        slotEqSlotPredicatesSet, slotToLiteralPredicatesList,
+                        slotToLiteralPredicatesSet, isNullPredicatesList, isNullPredicatesSet);
+            }
+        }
+        if (conjunct instanceof BinaryPredicate) {
+            Pair<Expr, Expr> pair = new Pair<>(conjunct.getChild(0), conjunct.getChild(1));
+            Pair<Expr, Expr> eqPair = new Pair<>(conjunct.getChild(1), conjunct.getChild(0));
+            if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof LiteralExpr) {
+                if (!slotToLiteralPredicatesSet.contains(pair)
+                    && !slotToLiteralPredicatesSet.contains(eqPair)) {
+                    slotToLiteralPredicatesSet.add(pair);
+                    slotToLiteralPredicatesList.add(conjunct);
+                }
+            } else if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof SlotRef) {
+                if (!slotEqSlotPredicatesSet.contains(pair)
+                    && !slotEqSlotPredicatesSet.contains(eqPair)) {
+                    slotEqSlotPredicatesSet.add(pair);
+                    slotEqSlotPredicatesList.add(conjunct);
+                }
+            }
+        } else if (conjunct instanceof IsNullPredicate) {
+            if (!isNullPredicatesSet.contains(conjunct.getChild(0))) {
+                isNullPredicatesSet.add(conjunct.getChild(0));
+                isNullPredicatesList.add(conjunct);
+            }
+        }
+    }
+
+    private void inferSlotPredicates(ArrayList<Expr> slotEqSlotPredicatesList,
+                                    Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                    ArrayList<Expr> slotToLiteralPredicatesList,
+                                    ArrayList<Expr> newPredicatesList,
+                                    Analyzer analyzer) {
+        ArrayList<Expr> tmpSlotToLiteralPredicatesList = new ArrayList<>();
+        for (Expr slotToLiteral : slotToLiteralPredicatesList) {
+            buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+        }
+
+        int tmpSize = 0;
+        do {
+            int startSize = tmpSlotToLiteralPredicatesList.size();
+
+            for (int index = 0; index < tmpSlotToLiteralPredicatesList.size(); ++index) {
+                Expr slotToLiteral = tmpSlotToLiteralPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            for (int index = 0; index < newPredicatesList.size(); ++index) {
+                Expr slotToLiteral = newPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            int endSize = tmpSlotToLiteralPredicatesList.size();
+            tmpSize = endSize - startSize;
+
+        } while (tmpSize != 0);
+    }
+
+    private void buildNewBinaryPredicate(Expr slotToLiteral,
+                                         ArrayList<Expr> slotEqSlotPredicatesList,
+                                         Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                         ArrayList<Expr> newPredicatesList,
+                                         ArrayList<Expr> tmpSlotToLiteralPredicatesList,
+                                         Analyzer analyzer) {
+        SlotRef checkSlot = slotToLiteral.getChild(0).unwrapSlotRef();
+        for (Expr conjunct : slotEqSlotPredicatesList) {
+            SlotRef leftSlot = conjunct.getChild(0).unwrapSlotRef();
+            SlotRef rightSlot = conjunct.getChild(1).unwrapSlotRef();
+
+            if (checkSlot.simple_equals(leftSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, rightSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, rightSlot));
+            } else if (checkSlot.simple_equals(rightSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, leftSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, leftSlot));
+            }
+        }
+    }
+
+    private boolean isNeedInfer(SlotRef checkSlot, SlotRef newSlot) {
+        JoinOperator jop = newSlot.getDesc().getParent().getRef().getJoinOp();
+        boolean ret = false;
+        if (jop == null) {
+            JoinOperator checkJop = checkSlot.getDesc().getParent().getRef().getJoinOp();
+            if (checkJop.isInnerJoin()
+                    || checkJop == JoinOperator.RIGHT_SEMI_JOIN) {
+                ret = true;
+            } else if (checkJop == JoinOperator.RIGHT_OUTER_JOIN
+                    || checkJop == JoinOperator.RIGHT_ANTI_JOIN) {
+                ret = true;
+            }
+        } else if (jop.isInnerJoin()
+                || jop == JoinOperator.LEFT_SEMI_JOIN) {
+            ret = true;
+        } else if (jop == JoinOperator.LEFT_OUTER_JOIN
+                || jop == JoinOperator.LEFT_ANTI_JOIN) {
+            ret = true;
+        }
+        return ret;
+    }
+
+    private Expr genNewBinaryPredicate(Analyzer analyzer, Expr oldExpr, Expr newSlot) {
+        if (oldExpr instanceof BinaryPredicate) {
+            BinaryPredicate oldBP = (BinaryPredicate) oldExpr;
+            BinaryPredicate newBP = new BinaryPredicate(oldBP.getOp(), newSlot, oldBP.getChild(1));
+            newBP.analyzeNoThrow(analyzer);
+            return newBP;
+        }
+        return oldExpr;
+    }
+
+    private void addNewBinaryPredicate(Expr expr,
+                                       Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                       ArrayList<Expr> newPredicatesList,
+                                       ArrayList<Expr> tmpSlotToLiteralPredicatesList,
+                                       boolean needAddNewPredicatesList) {
+        if (expr instanceof BinaryPredicate) {
+            BinaryPredicate newBP = (BinaryPredicate) expr;
+            Pair<Expr, Expr> pair = new Pair<>(newBP.getChild(0), newBP.getChild(1));
+            if (!slotToLiteralPredicatesSet.contains(pair)) {
+                slotToLiteralPredicatesSet.add(pair);
+                if (needAddNewPredicatesList) {
+                    newPredicatesList.add(newBP);

Review comment:
       Should the new predicate also be de-duplicated?
   for example
   a=b and b=c and a=1 and c=1
   The b=1 may be inferred twice.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/rewrite/InferFiltersRule.java
##########
@@ -0,0 +1,302 @@
+// 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.rewrite;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.BinaryPredicate;
+import org.apache.doris.analysis.CompoundPredicate;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.IsNullPredicate;
+import org.apache.doris.analysis.JoinOperator;
+import org.apache.doris.analysis.LiteralExpr;
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+
+import com.google.common.collect.Sets;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * The function of this rule is to derive a new predicate based on the current predicate.
+ * eg.
+ * t1.id = t2.id and t2.id = t3.id and t3.id = 100;
+ * -->
+ * t1.id = 100 and t2.id = 100 and t3.id = 100;
+ *
+ * 1. Register a new rule InferFiltersRule and add it to GlobalState.
+ * 2. Traverse Conjunct to construct on/where equivalence connection, numerical connection and isNullPredicate.
+ * 3. Use Warshall to infer all equivalence connections
+ * 4. Construct additional numerical connections and isNullPredicate
+ */
+public class InferFiltersRule implements ExprRewriteRule {
+    private final static Logger LOG = LogManager.getLogger(InferFiltersRule.class);
+    public static InferFiltersRule INSTANCE = new InferFiltersRule();
+
+    @Override
+    public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        if (expr == null) {
+            return null;
+        } else if (!analyzer.enableInferPredicate()) {
+            return expr;
+        } else {
+            ArrayList<Expr> slotEqSlotPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> slotToLiteralPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> newPredicatesList = new ArrayList<>();
+            ArrayList<Expr> isNullPredicatesList = new ArrayList<>();
+            Set<Expr> isNullPredicatesSet = Sets.newHashSet();
+
+            initAllStructure(expr, slotEqSlotPredicatesList, slotEqSlotPredicatesSet,
+                    slotToLiteralPredicatesList, slotToLiteralPredicatesSet,
+                    isNullPredicatesList, isNullPredicatesSet);
+
+            inferSlotPredicates(slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    slotToLiteralPredicatesList, newPredicatesList, analyzer);
+
+            inferIsNullPredicates(slotEqSlotPredicatesList, isNullPredicatesList,
+                    isNullPredicatesSet, newPredicatesList, analyzer);
+            
+            if (!newPredicatesList.isEmpty()) {
+                Expr rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, expr, newPredicatesList.get(0));
+                for (int index = 1; index < newPredicatesList.size(); index++) {
+                    rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, rewriteExpr, newPredicatesList.get(index));
+                }
+                return rewriteExpr;
+            }
+        }
+        return expr;
+    }
+
+    private void initAllStructure(Expr conjunct,
+                                  ArrayList<Expr> slotEqSlotPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet,
+                                  ArrayList<Expr> slotToLiteralPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                  ArrayList<Expr> isNullPredicatesList,
+                                  Set<Expr> isNullPredicatesSet) {
+        if (conjunct instanceof CompoundPredicate) {
+            for (int index = 0; index < conjunct.getChildren().size(); ++index) {
+                initAllStructure(conjunct.getChild(index), slotEqSlotPredicatesList,
+                        slotEqSlotPredicatesSet, slotToLiteralPredicatesList,
+                        slotToLiteralPredicatesSet, isNullPredicatesList, isNullPredicatesSet);
+            }
+        }
+        if (conjunct instanceof BinaryPredicate) {
+            Pair<Expr, Expr> pair = new Pair<>(conjunct.getChild(0), conjunct.getChild(1));
+            Pair<Expr, Expr> eqPair = new Pair<>(conjunct.getChild(1), conjunct.getChild(0));
+            if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof LiteralExpr) {
+                if (!slotToLiteralPredicatesSet.contains(pair)
+                    && !slotToLiteralPredicatesSet.contains(eqPair)) {
+                    slotToLiteralPredicatesSet.add(pair);
+                    slotToLiteralPredicatesList.add(conjunct);
+                }
+            } else if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof SlotRef) {
+                if (!slotEqSlotPredicatesSet.contains(pair)
+                    && !slotEqSlotPredicatesSet.contains(eqPair)) {
+                    slotEqSlotPredicatesSet.add(pair);
+                    slotEqSlotPredicatesList.add(conjunct);
+                }
+            }
+        } else if (conjunct instanceof IsNullPredicate) {
+            if (!isNullPredicatesSet.contains(conjunct.getChild(0))) {
+                isNullPredicatesSet.add(conjunct.getChild(0));
+                isNullPredicatesList.add(conjunct);
+            }
+        }
+    }
+
+    private void inferSlotPredicates(ArrayList<Expr> slotEqSlotPredicatesList,
+                                    Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                    ArrayList<Expr> slotToLiteralPredicatesList,
+                                    ArrayList<Expr> newPredicatesList,
+                                    Analyzer analyzer) {
+        ArrayList<Expr> tmpSlotToLiteralPredicatesList = new ArrayList<>();
+        for (Expr slotToLiteral : slotToLiteralPredicatesList) {
+            buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+        }
+
+        int tmpSize = 0;
+        do {
+            int startSize = tmpSlotToLiteralPredicatesList.size();
+
+            for (int index = 0; index < tmpSlotToLiteralPredicatesList.size(); ++index) {
+                Expr slotToLiteral = tmpSlotToLiteralPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            for (int index = 0; index < newPredicatesList.size(); ++index) {
+                Expr slotToLiteral = newPredicatesList.get(index);

Review comment:
       Although this writing is functionally correct, there may be a risk of infinite loop if the logic is wrong.
   Is it better to derive all the expressions of a single slotToLiteral predicate at once?

##########
File path: fe/fe-core/src/main/java/org/apache/doris/rewrite/InferFiltersRule.java
##########
@@ -0,0 +1,302 @@
+// 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.rewrite;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.BinaryPredicate;
+import org.apache.doris.analysis.CompoundPredicate;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.IsNullPredicate;
+import org.apache.doris.analysis.JoinOperator;
+import org.apache.doris.analysis.LiteralExpr;
+import org.apache.doris.analysis.SlotRef;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Pair;
+
+import com.google.common.collect.Sets;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * The function of this rule is to derive a new predicate based on the current predicate.
+ * eg.
+ * t1.id = t2.id and t2.id = t3.id and t3.id = 100;
+ * -->
+ * t1.id = 100 and t2.id = 100 and t3.id = 100;
+ *
+ * 1. Register a new rule InferFiltersRule and add it to GlobalState.
+ * 2. Traverse Conjunct to construct on/where equivalence connection, numerical connection and isNullPredicate.
+ * 3. Use Warshall to infer all equivalence connections
+ * 4. Construct additional numerical connections and isNullPredicate
+ */
+public class InferFiltersRule implements ExprRewriteRule {
+    private final static Logger LOG = LogManager.getLogger(InferFiltersRule.class);
+    public static InferFiltersRule INSTANCE = new InferFiltersRule();
+
+    @Override
+    public Expr apply(Expr expr, Analyzer analyzer) throws AnalysisException {
+        if (expr == null) {
+            return null;
+        } else if (!analyzer.enableInferPredicate()) {
+            return expr;
+        } else {
+            ArrayList<Expr> slotEqSlotPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> slotToLiteralPredicatesList = new ArrayList<>();
+            Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet = Sets.newHashSet();
+            ArrayList<Expr> newPredicatesList = new ArrayList<>();
+            ArrayList<Expr> isNullPredicatesList = new ArrayList<>();
+            Set<Expr> isNullPredicatesSet = Sets.newHashSet();
+
+            initAllStructure(expr, slotEqSlotPredicatesList, slotEqSlotPredicatesSet,
+                    slotToLiteralPredicatesList, slotToLiteralPredicatesSet,
+                    isNullPredicatesList, isNullPredicatesSet);
+
+            inferSlotPredicates(slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    slotToLiteralPredicatesList, newPredicatesList, analyzer);
+
+            inferIsNullPredicates(slotEqSlotPredicatesList, isNullPredicatesList,
+                    isNullPredicatesSet, newPredicatesList, analyzer);
+            
+            if (!newPredicatesList.isEmpty()) {
+                Expr rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, expr, newPredicatesList.get(0));
+                for (int index = 1; index < newPredicatesList.size(); index++) {
+                    rewriteExpr = new CompoundPredicate(CompoundPredicate.Operator.AND, rewriteExpr, newPredicatesList.get(index));
+                }
+                return rewriteExpr;
+            }
+        }
+        return expr;
+    }
+
+    private void initAllStructure(Expr conjunct,
+                                  ArrayList<Expr> slotEqSlotPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotEqSlotPredicatesSet,
+                                  ArrayList<Expr> slotToLiteralPredicatesList,
+                                  Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                  ArrayList<Expr> isNullPredicatesList,
+                                  Set<Expr> isNullPredicatesSet) {
+        if (conjunct instanceof CompoundPredicate) {
+            for (int index = 0; index < conjunct.getChildren().size(); ++index) {
+                initAllStructure(conjunct.getChild(index), slotEqSlotPredicatesList,
+                        slotEqSlotPredicatesSet, slotToLiteralPredicatesList,
+                        slotToLiteralPredicatesSet, isNullPredicatesList, isNullPredicatesSet);
+            }
+        }
+        if (conjunct instanceof BinaryPredicate) {
+            Pair<Expr, Expr> pair = new Pair<>(conjunct.getChild(0), conjunct.getChild(1));
+            Pair<Expr, Expr> eqPair = new Pair<>(conjunct.getChild(1), conjunct.getChild(0));
+            if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof LiteralExpr) {
+                if (!slotToLiteralPredicatesSet.contains(pair)
+                    && !slotToLiteralPredicatesSet.contains(eqPair)) {
+                    slotToLiteralPredicatesSet.add(pair);
+                    slotToLiteralPredicatesList.add(conjunct);
+                }
+            } else if (conjunct.getChild(0) instanceof SlotRef
+                    && conjunct.getChild(1) instanceof SlotRef) {
+                if (!slotEqSlotPredicatesSet.contains(pair)
+                    && !slotEqSlotPredicatesSet.contains(eqPair)) {
+                    slotEqSlotPredicatesSet.add(pair);
+                    slotEqSlotPredicatesList.add(conjunct);
+                }
+            }
+        } else if (conjunct instanceof IsNullPredicate) {
+            if (!isNullPredicatesSet.contains(conjunct.getChild(0))) {
+                isNullPredicatesSet.add(conjunct.getChild(0));
+                isNullPredicatesList.add(conjunct);
+            }
+        }
+    }
+
+    private void inferSlotPredicates(ArrayList<Expr> slotEqSlotPredicatesList,
+                                    Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                    ArrayList<Expr> slotToLiteralPredicatesList,
+                                    ArrayList<Expr> newPredicatesList,
+                                    Analyzer analyzer) {
+        ArrayList<Expr> tmpSlotToLiteralPredicatesList = new ArrayList<>();
+        for (Expr slotToLiteral : slotToLiteralPredicatesList) {
+            buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                    newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+        }
+
+        int tmpSize = 0;
+        do {
+            int startSize = tmpSlotToLiteralPredicatesList.size();
+
+            for (int index = 0; index < tmpSlotToLiteralPredicatesList.size(); ++index) {
+                Expr slotToLiteral = tmpSlotToLiteralPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            for (int index = 0; index < newPredicatesList.size(); ++index) {
+                Expr slotToLiteral = newPredicatesList.get(index);
+                buildNewBinaryPredicate(slotToLiteral, slotEqSlotPredicatesList, slotToLiteralPredicatesSet,
+                        newPredicatesList, tmpSlotToLiteralPredicatesList, analyzer);
+            }
+
+            int endSize = tmpSlotToLiteralPredicatesList.size();
+            tmpSize = endSize - startSize;
+
+        } while (tmpSize != 0);
+    }
+
+    private void buildNewBinaryPredicate(Expr slotToLiteral,
+                                         ArrayList<Expr> slotEqSlotPredicatesList,
+                                         Set<Pair<Expr, Expr>> slotToLiteralPredicatesSet,
+                                         ArrayList<Expr> newPredicatesList,
+                                         ArrayList<Expr> tmpSlotToLiteralPredicatesList,
+                                         Analyzer analyzer) {
+        SlotRef checkSlot = slotToLiteral.getChild(0).unwrapSlotRef();
+        for (Expr conjunct : slotEqSlotPredicatesList) {
+            SlotRef leftSlot = conjunct.getChild(0).unwrapSlotRef();
+            SlotRef rightSlot = conjunct.getChild(1).unwrapSlotRef();
+
+            if (checkSlot.simple_equals(leftSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, rightSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, rightSlot));
+            } else if (checkSlot.simple_equals(rightSlot)) {
+                addNewBinaryPredicate(genNewBinaryPredicate(analyzer, slotToLiteral, leftSlot),
+                        slotToLiteralPredicatesSet, newPredicatesList,
+                        tmpSlotToLiteralPredicatesList,
+                        isNeedInfer(checkSlot, leftSlot));
+            }
+        }
+    }
+
+    private boolean isNeedInfer(SlotRef checkSlot, SlotRef newSlot) {
+        JoinOperator jop = newSlot.getDesc().getParent().getRef().getJoinOp();

Review comment:
       It is wrong to use JoinOperator directly to judge the relationship between the table and the table.
   For example:
   From a inner join b left join c on b.id=c.id and b.id=1;
   checkSlot is b
   newSlot is c
   b join op: inner join
   c join op: left join
   The b join op is inner join but it still cannot infer right?
   
   It is better to use params of analyzer to judge the join op between two table.




-- 
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