924060929 commented on code in PR #11035:
URL: https://github.com/apache/doris/pull/11035#discussion_r930952715


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java:
##########
@@ -33,6 +33,7 @@ public enum RuleType {
     BINDING_SORT_SLOT(RuleTypeClass.REWRITE),
     BINDING_PROJECT_FUNCTION(RuleTypeClass.REWRITE),
     BINDING_AGGREGATE_FUNCTION(RuleTypeClass.REWRITE),
+    BINDING_ALIAS_SLOT(RuleTypeClass.REWRITE),

Review Comment:
   ```suggestion
       BINDING_ALIAS_SUBQUERY_SLOT(RuleTypeClass.REWRITE),
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSubQueryAlias.java:
##########
@@ -0,0 +1,41 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.analysis;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * Rule to bind relation when encounter sub query and alias
+ */
+public class BindSubQueryAlias implements AnalysisRuleFactory {
+    @Override
+    public List<Rule> buildRules() {
+        return ImmutableList.of(
+                RuleType.BINDING_ALIAS_SLOT.build(
+                        logicalSubQueryAlias().then(alias -> new 
LogicalSubQueryAlias<>(alias.getAlias(), alias.child())

Review Comment:
   this line do nothing?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateAliasNode.java:
##########
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.analysis;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.plans.GroupPlan;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Eliminate the logical sub query and alias node after analyze and before 
rewrite
+ * If we match the alias node and return its child node, in the execute() of 
the job
+ *
+ * TODO: refactor group merge strategy to support the feature above
+ */
+public class EliminateAliasNode implements AnalysisRuleFactory {
+    @Override
+    public List<Rule> buildRules() {
+        return ImmutableList.of(
+                RuleType.PROJECT_ELIMINATE_ALIAS_NODE.build(
+                        logicalProject().then(project -> 
eliminateSubQueryAliasNode(project, project.children()))

Review Comment:
   why not use this pattern and save work to judge child type is 
LogicalSubqueryAlias?
   
   ```
   logicalProject(logicalSubqueryAlias()).then(...)
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -190,11 +194,38 @@ public LogicalPlan 
visitRegularQuerySpecification(RegularQuerySpecificationConte
     /**
      * Create an aliased table reference. This is typically used in FROM 
clauses.
      */
+    private LogicalPlan applyAlias(TableAliasContext ctx, LogicalPlan plan) {
+        if (null != ctx.strictIdentifier()) {
+            String alias = ctx.strictIdentifier().getText();
+            if (null != ctx.identifierList()) {
+                // List<String> colName = 
visitIdentifierSeq(ctx.identifierList().identifierSeq());
+                // TODO: multi-colName

Review Comment:
   You should throw a ParseException here



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupExpression.java:
##########
@@ -167,6 +168,9 @@ public boolean equals(Object o) {
             return false;
         }
         GroupExpression that = (GroupExpression) o;
+        if (plan instanceof LogicalOlapScan) {

Review Comment:
   You should add a comment here to show why LogicalOlapScan is not equals



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