morrySnow commented on code in PR #12461:
URL: https://github.com/apache/doris/pull/12461#discussion_r966127406


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -165,6 +167,8 @@
  */
 public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
 
+    private final IdGenerator<RelationId> idGenerator = 
RelationId.createGenerator();

Review Comment:
   add a todo, we need to move it to statement context finally



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java:
##########
@@ -41,35 +42,40 @@
  * Represent a relation plan node that has not been bound.
  */
 public class UnboundRelation extends LogicalLeaf implements Relation, Unbound {
+
+    public final RelationId id;

Review Comment:
   private, and add a getter



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java:
##########
@@ -81,7 +86,8 @@ public boolean equals(Object o) {
             return false;
         }
         LogicalRelation that = (LogicalRelation) o;
-        return Objects.equals(table.getId(), that.table.getId()) && 
Objects.equals(qualifier, that.qualifier);
+        return Objects.equals(id, that.id)

Review Comment:
   just check relation id in hashcode and equals



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java:
##########
@@ -36,24 +37,29 @@
  */
 public abstract class PhysicalRelation extends PhysicalLeaf implements Scan {
 
+    public final RelationId id;

Review Comment:
   private



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java:
##########
@@ -107,7 +109,8 @@ public boolean equals(Object o) {
             return false;
         }
         PhysicalOlapScan that = (PhysicalOlapScan) o;
-        return selectedIndexId == that.selectedIndexId
+        return Objects.equals(id, that.id)

Review Comment:
   just compare id



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/RelationId.java:
##########
@@ -0,0 +1,71 @@
+// 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.plans;
+
+import org.apache.doris.common.Id;
+import org.apache.doris.common.IdGenerator;
+
+import java.util.Objects;
+
+/**
+ * relation id
+ */
+public class RelationId extends Id<RelationId> {
+    public RelationId(int id) {
+        super(id);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        RelationId relationId = (RelationId) o;
+        return id == relationId.id;
+    }
+
+    /**
+     * Should be only called by {@link 
org.apache.doris.nereids.trees.expressions.NamedExpressionUtil}.
+     */
+    public static IdGenerator<RelationId> createGenerator() {
+        return new IdGenerator<RelationId>() {
+            @Override
+            public RelationId getNextId() {
+                return new RelationId(nextId++);
+            }
+
+            @Override
+            public RelationId getMaxId() {
+                return new RelationId(nextId++);

Review Comment:
   ```suggestion
                   return new RelationId(nextId);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

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


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

Reply via email to