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/12 02:52:53 UTC

[GitHub] [incubator-doris] morrySnow commented on a diff in pull request #9506: [Feature](Nereids) Data structure of comparison predicate

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