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/06/29 13:23:05 UTC

[GitHub] [doris] Kikyou1997 opened a new pull request, #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Kikyou1997 opened a new pull request, #10499:
URL: https://github.com/apache/doris/pull/10499

   # Proposed changes
   
   Issue Number: no issue
   
   ## Problem Summary:
   
   Since we will do the column prune with project node, so we need compact the project outputs to the PlanNode in `PhysicalPlanTranslator::visitPhysicalProject`
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (No)
   2. Has unit tests been added: (No)
   3. Has document been added or modified: (No)
   4. Does it need to update dependencies: (No)
   5. Are there any changes that cannot be rolled back: (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] [doris] morrySnow commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PhysicalPlanTranslator.java:
##########
@@ -263,7 +279,43 @@ public PlanFragment visitPhysicalHashJoin(
     @Override
     public PlanFragment visitPhysicalProject(
             PhysicalUnaryPlan<PhysicalProject, Plan> projectPlan, PlanTranslatorContext context) {
-        return visit(projectPlan.child(0), context);
+        PhysicalProject physicalProject = projectPlan.getOperator();
+        List<Expr> execExprList = physicalProject.getProjects()
+                .stream()
+                .map(e -> ExpressionConverter.convert(e, context))
+                .collect(Collectors.toList());
+        PlanFragment inputFragment = visit(projectPlan.child(0), context);
+        PlanNode planNode = inputFragment.getPlanRoot();
+        List<Expr> conjunctList = planNode.getConjuncts();

Review Comment:
   ```suggestion
           List<Expr> inputPredicates = planNode.getConjuncts();
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PhysicalPlanTranslator.java:
##########
@@ -263,7 +279,43 @@ public PlanFragment visitPhysicalHashJoin(
     @Override
     public PlanFragment visitPhysicalProject(
             PhysicalUnaryPlan<PhysicalProject, Plan> projectPlan, PlanTranslatorContext context) {
-        return visit(projectPlan.child(0), context);
+        PhysicalProject physicalProject = projectPlan.getOperator();
+        List<Expr> execExprList = physicalProject.getProjects()

Review Comment:
   ```suggestion
           List<Expr> projectExprList = physicalProject.getProjects()
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PhysicalPlanTranslator.java:
##########
@@ -263,7 +279,43 @@ public PlanFragment visitPhysicalHashJoin(
     @Override
     public PlanFragment visitPhysicalProject(
             PhysicalUnaryPlan<PhysicalProject, Plan> projectPlan, PlanTranslatorContext context) {
-        return visit(projectPlan.child(0), context);
+        PhysicalProject physicalProject = projectPlan.getOperator();
+        List<Expr> execExprList = physicalProject.getProjects()
+                .stream()
+                .map(e -> ExpressionConverter.convert(e, context))
+                .collect(Collectors.toList());
+        PlanFragment inputFragment = visit(projectPlan.child(0), context);
+        PlanNode planNode = inputFragment.getPlanRoot();

Review Comment:
   ```suggestion
           PlanNode inputNode = inputFragment.getPlanRoot();
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PhysicalPlanTranslator.java:
##########
@@ -263,7 +279,43 @@ public PlanFragment visitPhysicalHashJoin(
     @Override
     public PlanFragment visitPhysicalProject(
             PhysicalUnaryPlan<PhysicalProject, Plan> projectPlan, PlanTranslatorContext context) {
-        return visit(projectPlan.child(0), context);
+        PhysicalProject physicalProject = projectPlan.getOperator();
+        List<Expr> execExprList = physicalProject.getProjects()
+                .stream()
+                .map(e -> ExpressionConverter.convert(e, context))
+                .collect(Collectors.toList());
+        PlanFragment inputFragment = visit(projectPlan.child(0), context);
+        PlanNode planNode = inputFragment.getPlanRoot();
+        List<Expr> conjunctList = planNode.getConjuncts();
+        Set<Integer> slotIdList = new HashSet<>();

Review Comment:
   ```suggestion
           Set<Integer> requiredSlotIds = new HashSet<>();
   ```



-- 
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] [doris] github-actions[bot] commented on pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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

   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] [doris] Kikyou1997 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
Kikyou1997 commented on code in PR #10499:
URL: https://github.com/apache/doris/pull/10499#discussion_r911146736


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {
+
+    private static final FindFunction findFunction = new FindFunction();

Review Comment:
   > I think we can add collect function in TreeNode like this
   > 
   > ```java
   > default List<TreeNode<NODE_TYPE>> collect(Predicate<TreeNode<NODE_TYPE>> predicate) {
   >     ImmutableList.Builder<TreeNode<NODE_TYPE>> result = ImmutableList.builder();
   >     foreach(node -> {
   >         if (predicate.test(node)) {
   >             result.add(node);
   >         }
   >     });
   >     return result.build();
   > }
   > ```
   > 
   > and find function:
   > 
   > ```java
   > rootExpression.collect(BoundFunction.class::isInstance)
   > ```
   
   素晴らし



-- 
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] [doris] morrySnow commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java:
##########
@@ -67,11 +70,17 @@ public void plan(StatementBase queryStmt,
         physicalPlanTranslator.translatePlan(physicalPlan, planContext);
         fragments = new ArrayList<>(planContext.getPlanFragmentList());
         PlanFragment root = fragments.get(fragments.size() - 1);
+        for (PlanFragment fragment : fragments) {
+            fragment.finalize(queryStmt);
+        }
         root.setOutputExprs(queryStmt.getResultExprs());
         if (VectorizedUtil.isVectorized()) {
             root.getPlanRoot().convertToVectoriezd();
         }
         scanNodeList = planContext.getScanNodeList();
+        descTable = planContext.getDescTable();
+        Collections.reverse(fragments);
+        planContext.getDescTable().computeStatAndMemLayout();

Review Comment:
   vectorized engine do not need this



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {

Review Comment:
   use collect directly



##########
fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java:
##########
@@ -237,7 +238,8 @@ public Coordinator(ConnectContext context, Analyzer analyzer, Planner planner) {
         this.queryId = context.queryId();
         this.fragments = planner.getFragments();
         this.scanNodes = planner.getScanNodes();
-        this.descTable = analyzer.getDescTbl().toThrift();
+        this.descTable = planner instanceof NereidsPlanner ? planner.getDescTable().toThrift()
+                : analyzer.getDescTbl().toThrift();

Review Comment:
   both NereidsPlanner and OriginalPlanner already implement interface getDescTable, we could call getDescTable for both of them



-- 
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] [doris] github-actions[bot] commented on pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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

   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] [doris] Kikyou1997 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
Kikyou1997 commented on code in PR #10499:
URL: https://github.com/apache/doris/pull/10499#discussion_r911002150


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -138,8 +147,13 @@ public PlanFragment visitPhysicalOlapScan(
         List<Slot> slotList = olapScan.getOutput();
         PhysicalOlapScan physicalOlapScan = olapScan.getOperator();
         OlapTable olapTable = physicalOlapScan.getTable();
+        List<Expr> execConjunctsList = physicalOlapScan
+                .getExpressions()
+                .stream()
+                .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toList());
         TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, context, olapTable);
         OlapScanNode olapScanNode = new OlapScanNode(context.nextNodeId(), tupleDescriptor, olapTable.getName());

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] [doris] 924060929 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {
+
+    private static final FindFunction findFunction = new FindFunction();

Review Comment:
   I think we can add collect function in TreeNode like this
   ```java
   default List<TreeNode<NODE_TYPE>> collect(Predicate<TreeNode<NODE_TYPE>> predicate) {
       ImmutableList.Builder<TreeNode<NODE_TYPE>> result = ImmutableList.builder();
       foreach(node -> {
           if (predicate.test(node)) {
               result.add(node);
           }
       });
       return result.build();
   }
   ```
   
   and find function:
   ```java
   rootExpresion.collect(BoundFunction.class::isInstance)
   ```



-- 
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] [doris] Kikyou1997 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
Kikyou1997 commented on code in PR #10499:
URL: https://github.com/apache/doris/pull/10499#discussion_r911009838


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -138,8 +147,13 @@ public PlanFragment visitPhysicalOlapScan(
         List<Slot> slotList = olapScan.getOutput();
         PhysicalOlapScan physicalOlapScan = olapScan.getOperator();
         OlapTable olapTable = physicalOlapScan.getTable();
+        List<Expr> execConjunctsList = physicalOlapScan
+                .getExpressions()
+                .stream()
+                .map(e -> ExpressionTranslator.translate(e, context)).collect(Collectors.toList());
         TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, context, olapTable);
         OlapScanNode olapScanNode = new OlapScanNode(context.nextNodeId(), tupleDescriptor, olapTable.getName());
+        olapScanNode.addConjuncts(execConjunctsList);
         context.addScanNode(olapScanNode);

Review Comment:
   converted at NereidPlanner



-- 
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] [doris] morrySnow commented on pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
morrySnow commented on PR #10499:
URL: https://github.com/apache/doris/pull/10499#issuecomment-1170293473

   i suggest collect all plan translator's file into a new sub package under nereids for reading easily


-- 
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] [doris] 924060929 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {
+
+    private static final FindFunction findFunction = new FindFunction();

Review Comment:
   I think we can add collect function in TreeNode like this
   ```java
   default List<TreeNode<NODE_TYPE>> collect(Predicate<TreeNode<NODE_TYPE>> predicate) {
       ImmutableList.Builder<TreeNode<NODE_TYPE>> result = ImmutableList.builder();
       foreach(node -> {
           if (predicate.test(node)) {
               result.add(node);
           }
       });
       return result.build();
   }
   ```
   
   and find function:
   ```java
   rootExpression.collect(BoundFunction.class::isInstance)
   ```



-- 
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] [doris] EmmyMiao87 merged pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


-- 
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] [doris] Kikyou1997 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
Kikyou1997 commented on code in PR #10499:
URL: https://github.com/apache/doris/pull/10499#discussion_r911146142


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {
+
+    private static final FindFunction findFunction = new FindFunction();

Review Comment:
    素晴らし



-- 
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] [doris] morrySnow commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -94,17 +100,20 @@ public PlanFragment visitPhysicalAggregation(
 
         List<Expression> groupByExpressionList = physicalAggregation.getGroupByExprList();
         ArrayList<Expr> execGroupingExpressions = groupByExpressionList.stream()
-                .map(e -> ExpressionConverter.convert(e, context)).collect(Collectors.toCollection(ArrayList::new));
+                .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toCollection(ArrayList::new));
 
         List<NamedExpression> outputExpressionList = physicalAggregation.getOutputExpressionList();
-        // TODO: agg function could be other expr type either
         ArrayList<FunctionCallExpr> execAggExpressions = outputExpressionList.stream()
-                .map(e -> (FunctionCallExpr) ExpressionConverter.convert(e, context))
+                .map(FindFunction::find
+                )

Review Comment:
   this parenthesis‘s position is weird



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/FindFunction.java:
##########
@@ -0,0 +1,55 @@
+// 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.trees.expressions.functions.BoundFunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Find all function call in the given expression tree.
+ */
+public class FindFunction extends ExpressionVisitor<Void, List<BoundFunction>> {
+
+    private static final FindFunction findFunction = new FindFunction();

Review Comment:
   ```suggestion
       private static final FindFunction INSTANCE = new FindFunction();
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/ExpressionTranslator.java:
##########
@@ -45,12 +58,12 @@
  * Used to convert expression of new optimizer to stale expr.
  */
 @SuppressWarnings("rawtypes")
-public class ExpressionConverter extends DefaultExpressionVisitor<Expr, PlanTranslatorContext> {
+public class ExpressionTranslator extends DefaultExpressionVisitor<Expr, PlanTranslatorContext> {
 
-    public static ExpressionConverter converter = new ExpressionConverter();
+    public static ExpressionTranslator translator = new ExpressionTranslator();
 
     public static Expr convert(Expression expression, PlanTranslatorContext planContext) {

Review Comment:
   ```suggestion
       public static Expr translate(Expression expression, PlanTranslatorContext planContext) {
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -94,17 +100,20 @@ public PlanFragment visitPhysicalAggregation(
 
         List<Expression> groupByExpressionList = physicalAggregation.getGroupByExprList();
         ArrayList<Expr> execGroupingExpressions = groupByExpressionList.stream()
-                .map(e -> ExpressionConverter.convert(e, context)).collect(Collectors.toCollection(ArrayList::new));
+                .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toCollection(ArrayList::new));
 
         List<NamedExpression> outputExpressionList = physicalAggregation.getOutputExpressionList();
-        // TODO: agg function could be other expr type either
         ArrayList<FunctionCallExpr> execAggExpressions = outputExpressionList.stream()
-                .map(e -> (FunctionCallExpr) ExpressionConverter.convert(e, context))
+                .map(FindFunction::find
+                )
+                .flatMap(List::stream)
+                .filter(x -> x instanceof AggregateFunction)

Review Comment:
   ```suggestion
                   .filter(AggregateFunction.class::isInstance)
   ```



-- 
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] [doris] EmmyMiao87 commented on a diff in pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -138,8 +147,13 @@ public PlanFragment visitPhysicalOlapScan(
         List<Slot> slotList = olapScan.getOutput();
         PhysicalOlapScan physicalOlapScan = olapScan.getOperator();
         OlapTable olapTable = physicalOlapScan.getTable();
+        List<Expr> execConjunctsList = physicalOlapScan
+                .getExpressions()
+                .stream()
+                .map(e -> ExpressionTranslator.convert(e, context)).collect(Collectors.toList());
         TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, context, olapTable);
         OlapScanNode olapScanNode = new OlapScanNode(context.nextNodeId(), tupleDescriptor, olapTable.getName());

Review Comment:
   All to thrift properties should be assigned in the translator, otherwise be cannot execute the query.
   Please check the properties of each PlanNode and add.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/translator/PhysicalPlanTranslator.java:
##########
@@ -138,8 +147,13 @@ public PlanFragment visitPhysicalOlapScan(
         List<Slot> slotList = olapScan.getOutput();
         PhysicalOlapScan physicalOlapScan = olapScan.getOperator();
         OlapTable olapTable = physicalOlapScan.getTable();
+        List<Expr> execConjunctsList = physicalOlapScan
+                .getExpressions()
+                .stream()
+                .map(e -> ExpressionTranslator.translate(e, context)).collect(Collectors.toList());
         TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, context, olapTable);
         OlapScanNode olapScanNode = new OlapScanNode(context.nextNodeId(), tupleDescriptor, olapTable.getName());
+        olapScanNode.addConjuncts(execConjunctsList);
         context.addScanNode(olapScanNode);

Review Comment:
   Vectorized and non-vectorized code use different properties, such as `vconjunct` and `conjuncts`.
   Our principle is that the properties used by both engines need to be translated before the vectorized code is stable.
   After the vectorized code runs stably, the useless code can be deleted



-- 
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] [doris] Kikyou1997 commented on pull request #10499: [Feature](neireids) Add support of ProjectNode in PlanTranslator

Posted by GitBox <gi...@apache.org>.
Kikyou1997 commented on PR #10499:
URL: https://github.com/apache/doris/pull/10499#issuecomment-1170700922

   > i suggest collect all plan translator's file into a new sub package under nereids for reading easily
   
   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