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 2022/05/11 10:44:29 UTC

[GitHub] [incubator-doris] EmmyMiao87 opened a new pull request, #9506: [Feature](Nereids) Data structure of comparison predicate

EmmyMiao87 opened a new pull request, #9506:
URL: https://github.com/apache/incubator-doris/pull/9506

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem Summary:
   
   1. The data structure of the comparison expression
   2. Refactored the inheritance and implementation relationship of tree node
   
   ```
           +-- ---- ---- ---+- ---- ---- ---- ---+- ---- ----- ---- ----TreeNode-----------------+
           |                |                    |                                               |
                                                                                                 |
           |                |                    |                                               |
                                                                                                 v
           v                v                    v                                           Abstract Tree Node
       Leaf Node        Unary Node          Binary Node                              +--------          ---------+
           |                |                    |                                   |        (children)         |
                                                                                     |                           |
           v                v                    v                                   v                           v
   Leaf Expression   Unary Expression      Binary Expression              +------Expression----+           Plan Node
           |                |                    |                        |                    |
                                                                          |                    |
           |                |                    |                        v                    v
           |                |                    +- ---- ---- -----> Comparison Predicate     Named Expr
                                                                                          +----   -------+
           |                |                                                             v              v
           |                +- -- --- --- --- --- --- --- --- --- --- --- --- --- ---> Alias Expr      Slot
                                                                                                         ^
           |                                                                                             |
           |                                                                                             |
           +---- --- ---- ------ ---- ------- ------ ------- --- ------ ------ ----- ---- ----- ----- ---+
   ```
   
   ## 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/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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870419251


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -73,10 +78,12 @@
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
+import com.clearspring.analytics.util.Lists;
+
 /**
  * Build an AST that consisting of logical plans.

Review Comment:
   done



-- 
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] [incubator-doris] EmmyMiao87 merged pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 merged PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506


-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870908336


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,
+    EQUAL_TO,
+    LESS_THAN,
+    GREATER_THAN,
+    LESS_THAN_EQUAL,
+    GREATER_THAN_EQUAL,
+    NULL_SAFE_EQUAL,
+    NOT_EXPRESSION,
+

Review Comment:
   done



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,
+    EQUAL_TO,
+    LESS_THAN,
+    GREATER_THAN,
+    LESS_THAN_EQUAL,
+    GREATER_THAN_EQUAL,
+    NULL_SAFE_EQUAL,
+    NOT_EXPRESSION,

Review Comment:
   done



-- 
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] [incubator-doris] github-actions[bot] commented on pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#issuecomment-1127285360

   PR approved by at least one committer and no changes requested.


-- 
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] [incubator-doris] github-actions[bot] commented on pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#issuecomment-1127285397

   PR approved by anyone and no changes requested.


-- 
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] [incubator-doris] 924060929 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
924060929 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870168998


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/Patterns.java:
##########
@@ -329,33 +328,31 @@ default PatternDescriptor<SlotReference, Expression> slotReference() {
     }
 
     /**
-     * create a binaryPredicate pattern.
+     * TODO create a ComparisonPredicate pattern.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate() {
-        return new PatternDescriptor<>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
-                defaultPromise()
-        );
-    }
 
     /**
-     * create a binaryPredicate pattern with operator type.
+     * TODO create a ComparisonPredicate pattern with children patterns.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate(Operator operator) {
-        return new PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
+
+    /**
+     * create a equal to predicate pattern.
+     */
+    default PatternDescriptor<EqualTo<Expression, Expression>, Expression> eqcomparisonPredicate() {
+        return new PatternDescriptor<>(
+                new Pattern<>(NodeType.EQ_COMPARISON_PREDICATE),
                 defaultPromise()
-        ).when(p -> p.getOperator() == operator);
+        );
     }
 
     /**
-     * create a binaryPredicate pattern with children patterns.
+     * create a equal to predicate pattern with children patterns.
      */
-    default <C1 extends Expression, C2 extends Expression> PatternDescriptor<BinaryPredicate<C1, C2>, Expression>
-            binaryPredicate(PatternDescriptor<C1, Expression> leftChildPattern,
+    default <C1 extends Expression, C2 extends Expression> PatternDescriptor<EqualTo<C1, C2>, Expression>
+    eqcomparisonPredicate(PatternDescriptor<C1, Expression> leftChildPattern,

Review Comment:
   ```suggestion
       equalsTo(PatternDescriptor<C1, Expression> leftChildPattern,
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/Patterns.java:
##########
@@ -329,33 +328,31 @@ default PatternDescriptor<SlotReference, Expression> slotReference() {
     }
 
     /**
-     * create a binaryPredicate pattern.
+     * TODO create a ComparisonPredicate pattern.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate() {
-        return new PatternDescriptor<>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
-                defaultPromise()
-        );
-    }
 
     /**
-     * create a binaryPredicate pattern with operator type.
+     * TODO create a ComparisonPredicate pattern with children patterns.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate(Operator operator) {
-        return new PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
+
+    /**
+     * create a equal to predicate pattern.
+     */
+    default PatternDescriptor<EqualTo<Expression, Expression>, Expression> eqcomparisonPredicate() {

Review Comment:
   ```suggestion
       default PatternDescriptor<EqualTo<Expression, Expression>, Expression> equalsTo() {
   ```



-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870418900


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/Patterns.java:
##########
@@ -329,33 +328,31 @@ default PatternDescriptor<SlotReference, Expression> slotReference() {
     }
 
     /**
-     * create a binaryPredicate pattern.
+     * TODO create a ComparisonPredicate pattern.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate() {
-        return new PatternDescriptor<>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
-                defaultPromise()
-        );
-    }
 
     /**
-     * create a binaryPredicate pattern with operator type.
+     * TODO create a ComparisonPredicate pattern with children patterns.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate(Operator operator) {
-        return new PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
+
+    /**
+     * create a equal to predicate pattern.
+     */
+    default PatternDescriptor<EqualTo<Expression, Expression>, Expression> eqcomparisonPredicate() {

Review Comment:
   done



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,

Review Comment:
   done



-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870908433


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"

Review Comment:
   done



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/NamedExpressionUtil.java:
##########
@@ -0,0 +1,33 @@
+// 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.trees.expressions;
+
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class NamedExpressionUtil {
+    /**
+     * Tool class for generate next ExprId.
+     */
+    static final UUID JVM_ID = UUID.randomUUID();

Review Comment:
   done



-- 
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] [incubator-doris] wangshuo128 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870352295


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -73,10 +78,12 @@
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
+import com.clearspring.analytics.util.Lists;
+
 /**
  * Build an AST that consisting of logical plans.

Review Comment:
   ```suggestion
    * Build a logical plan with unbound nodes.
   ```



-- 
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] [incubator-doris] wangshuo128 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870350086


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,

Review Comment:
   keep as same as the node class name?



-- 
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] [incubator-doris] jackwener commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
jackwener commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870167923


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/NotEqualTo.java:
##########
@@ -0,0 +1,44 @@
+// 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.trees.expressions;
+
+import org.apache.doris.nereids.exceptions.UnboundException;
+import org.apache.doris.nereids.trees.NodeType;
+
+public class NotEqualTo<LEFT_CHILD_TYPE extends Expression, RIGHT_CHILD_TYPE extends Expression>

Review Comment:
   `NotEqualTo` can be composed by `NotExpression` + `Equal`



-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870418536


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/NotEqualTo.java:
##########
@@ -0,0 +1,44 @@
+// 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.trees.expressions;
+
+import org.apache.doris.nereids.exceptions.UnboundException;
+import org.apache.doris.nereids.trees.NodeType;
+
+public class NotEqualTo<LEFT_CHILD_TYPE extends Expression, RIGHT_CHILD_TYPE extends Expression>

Review Comment:
   Changed



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/pattern/Patterns.java:
##########
@@ -329,33 +328,31 @@ default PatternDescriptor<SlotReference, Expression> slotReference() {
     }
 
     /**
-     * create a binaryPredicate pattern.
+     * TODO create a ComparisonPredicate pattern.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate() {
-        return new PatternDescriptor<>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
-                defaultPromise()
-        );
-    }
 
     /**
-     * create a binaryPredicate pattern with operator type.
+     * TODO create a ComparisonPredicate pattern with children patterns.
      */
-    default PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression> binaryPredicate(Operator operator) {
-        return new PatternDescriptor<BinaryPredicate<Expression, Expression>, Expression>(
-                new Pattern<>(NodeType.BINARY_PREDICATE),
+
+    /**
+     * create a equal to predicate pattern.
+     */
+    default PatternDescriptor<EqualTo<Expression, Expression>, Expression> eqcomparisonPredicate() {
+        return new PatternDescriptor<>(
+                new Pattern<>(NodeType.EQ_COMPARISON_PREDICATE),
                 defaultPromise()
-        ).when(p -> p.getOperator() == operator);
+        );
     }
 
     /**
-     * create a binaryPredicate pattern with children patterns.
+     * create a equal to predicate pattern with children patterns.
      */
-    default <C1 extends Expression, C2 extends Expression> PatternDescriptor<BinaryPredicate<C1, C2>, Expression>
-            binaryPredicate(PatternDescriptor<C1, Expression> leftChildPattern,
+    default <C1 extends Expression, C2 extends Expression> PatternDescriptor<EqualTo<C1, C2>, Expression>
+    eqcomparisonPredicate(PatternDescriptor<C1, Expression> leftChildPattern,

Review Comment:
   done



-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870907861


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"
  */
-public abstract class AbstractExpression<EXPR_TYPE extends AbstractExpression<EXPR_TYPE>>
-        extends AbstractTreeNode<EXPR_TYPE>
-        implements Expression<EXPR_TYPE> {
-
-    public AbstractExpression(NodeType type, Expression... children) {
-        super(type, children);
-    }
-
-    public DataType getDataType() throws UnboundException {
-        throw new UnboundException("dataType");
-    }
-
-    public String sql() throws UnboundException {
-        throw new UnboundException("sql");
-    }
-
-    public boolean nullable() throws UnboundException {
-        throw new UnboundException("nullable");
+public class ComparisonPredicate<
+    LEFT_CHILD_TYPE extends Expression,
+    RIGHT_CHILD_TYPE extends Expression>
+    extends Expression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>>
+    implements BinaryExpression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>,
+    LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
+
+    /**
+     * Constructor of ComparisonPredicate.
+     *
+     * @param nodeType node type of expression
+     * @param left     left child of comparison predicate

Review Comment:
   My IDE's automatic format adjustment is based on this, so it looks better, right?



-- 
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] [incubator-doris] wangshuo128 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870355121


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"
  */
-public abstract class AbstractExpression<EXPR_TYPE extends AbstractExpression<EXPR_TYPE>>
-        extends AbstractTreeNode<EXPR_TYPE>
-        implements Expression<EXPR_TYPE> {
-
-    public AbstractExpression(NodeType type, Expression... children) {
-        super(type, children);
-    }
-
-    public DataType getDataType() throws UnboundException {
-        throw new UnboundException("dataType");
-    }
-
-    public String sql() throws UnboundException {
-        throw new UnboundException("sql");
-    }
-
-    public boolean nullable() throws UnboundException {
-        throw new UnboundException("nullable");
+public class ComparisonPredicate<
+    LEFT_CHILD_TYPE extends Expression,
+    RIGHT_CHILD_TYPE extends Expression>
+    extends Expression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>>
+    implements BinaryExpression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>,
+    LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
+
+    /**
+     * Constructor of ComparisonPredicate.
+     *
+     * @param nodeType node type of expression
+     * @param left     left child of comparison predicate
+     * @param right    right child of comparison predicate
+     */
+    public ComparisonPredicate(NodeType nodeType, LEFT_CHILD_TYPE left, RIGHT_CHILD_TYPE right) {
+        super(nodeType, left, right);
     }
 
     @Override
-    public List<Expression> children() {
-        return (List) children;
+    public DataType getDataType() throws UnboundException {
+        return BooleanType.INSTANCE;
     }
 
     @Override
-    public Expression child(int index) {
-        return (Expression) children.get(index);
+    public String sql() {
+        return null;

Review Comment:
   Abstract class doesn't need to override this, right?



-- 
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] [incubator-doris] morrySnow commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870901700


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,
+    EQUAL_TO,
+    LESS_THAN,
+    GREATER_THAN,
+    LESS_THAN_EQUAL,
+    GREATER_THAN_EQUAL,
+    NULL_SAFE_EQUAL,
+    NOT_EXPRESSION,
+

Review Comment:
   remove this empty line?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/NodeType.java:
##########
@@ -43,7 +43,15 @@ public enum NodeType {
     UNBOUND_STAR,
     LITERAL,
     SLOT_REFERENCE,
-    BINARY_PREDICATE,
+    COMPARISON_PREDICATE,
+    EQUAL_TO,
+    LESS_THAN,
+    GREATER_THAN,
+    LESS_THAN_EQUAL,
+    GREATER_THAN_EQUAL,
+    NULL_SAFE_EQUAL,
+    NOT_EXPRESSION,

Review Comment:
   could we just named NOT as NOT?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/NamedExpressionUtil.java:
##########
@@ -0,0 +1,33 @@
+// 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.trees.expressions;
+
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class NamedExpressionUtil {
+    /**
+     * Tool class for generate next ExprId.
+     */
+    static final UUID JVM_ID = UUID.randomUUID();

Review Comment:
   private?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"

Review Comment:
   remove != from comment



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"
  */
-public abstract class AbstractExpression<EXPR_TYPE extends AbstractExpression<EXPR_TYPE>>
-        extends AbstractTreeNode<EXPR_TYPE>
-        implements Expression<EXPR_TYPE> {
-
-    public AbstractExpression(NodeType type, Expression... children) {
-        super(type, children);
-    }
-
-    public DataType getDataType() throws UnboundException {
-        throw new UnboundException("dataType");
-    }
-
-    public String sql() throws UnboundException {
-        throw new UnboundException("sql");
-    }
-
-    public boolean nullable() throws UnboundException {
-        throw new UnboundException("nullable");
+public class ComparisonPredicate<
+    LEFT_CHILD_TYPE extends Expression,
+    RIGHT_CHILD_TYPE extends Expression>
+    extends Expression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>>
+    implements BinaryExpression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>,
+    LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
+
+    /**
+     * Constructor of ComparisonPredicate.
+     *
+     * @param nodeType node type of expression
+     * @param left     left child of comparison predicate

Review Comment:
   do not need padding



-- 
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] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
EmmyMiao87 commented on code in PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#discussion_r870421188


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ComparisonPredicate.java:
##########
@@ -18,42 +18,39 @@
 package org.apache.doris.nereids.trees.expressions;
 
 import org.apache.doris.nereids.exceptions.UnboundException;
-import org.apache.doris.nereids.trees.AbstractTreeNode;
 import org.apache.doris.nereids.trees.NodeType;
+import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
 
-import java.util.List;
-
 /**
- * Abstract class for all Expression in Nereids.
+ * Comparison predicate expression.
+ * Such as: "=", "!=", "<", "<=", ">", ">=", "<=>"
  */
-public abstract class AbstractExpression<EXPR_TYPE extends AbstractExpression<EXPR_TYPE>>
-        extends AbstractTreeNode<EXPR_TYPE>
-        implements Expression<EXPR_TYPE> {
-
-    public AbstractExpression(NodeType type, Expression... children) {
-        super(type, children);
-    }
-
-    public DataType getDataType() throws UnboundException {
-        throw new UnboundException("dataType");
-    }
-
-    public String sql() throws UnboundException {
-        throw new UnboundException("sql");
-    }
-
-    public boolean nullable() throws UnboundException {
-        throw new UnboundException("nullable");
+public class ComparisonPredicate<
+    LEFT_CHILD_TYPE extends Expression,
+    RIGHT_CHILD_TYPE extends Expression>
+    extends Expression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>>
+    implements BinaryExpression<ComparisonPredicate<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE>,
+    LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
+
+    /**
+     * Constructor of ComparisonPredicate.
+     *
+     * @param nodeType node type of expression
+     * @param left     left child of comparison predicate
+     * @param right    right child of comparison predicate
+     */
+    public ComparisonPredicate(NodeType nodeType, LEFT_CHILD_TYPE left, RIGHT_CHILD_TYPE right) {
+        super(nodeType, left, right);
     }
 
     @Override
-    public List<Expression> children() {
-        return (List) children;
+    public DataType getDataType() throws UnboundException {
+        return BooleanType.INSTANCE;
     }
 
     @Override
-    public Expression child(int index) {
-        return (Expression) children.get(index);
+    public String sql() {
+        return null;

Review Comment:
   It implement a general function.



-- 
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] [incubator-doris] jackwener commented on pull request #9506: [Feature](Nereids) Data structure of comparison predicate

Posted by GitBox <gi...@apache.org>.
jackwener commented on PR #9506:
URL: https://github.com/apache/incubator-doris/pull/9506#issuecomment-1123563943

   Great Job!🥳


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