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/10/19 03:45:27 UTC

[GitHub] [doris] jackwener commented on a diff in pull request #13252: [fix](nerieds) Fix NPE caused by GroupExpression has null owner group when choosing best plan

jackwener commented on code in PR #13252:
URL: https://github.com/apache/doris/pull/13252#discussion_r998913714


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java:
##########
@@ -190,25 +190,31 @@ public Group getRoot() {
 
     private PhysicalPlan chooseBestPlan(Group rootGroup, PhysicalProperties physicalProperties)
             throws AnalysisException {
-        GroupExpression groupExpression = rootGroup.getLowestCostPlan(physicalProperties).orElseThrow(
-                () -> new AnalysisException("lowestCostPlans with physicalProperties doesn't exist")).second;
-        List<PhysicalProperties> inputPropertiesList = groupExpression.getInputPropertiesList(physicalProperties);
-
-        List<Plan> planChildren = Lists.newArrayList();
-        for (int i = 0; i < groupExpression.arity(); i++) {
-            planChildren.add(chooseBestPlan(groupExpression.child(i), inputPropertiesList.get(i)));
-        }
-
-        Plan plan = groupExpression.getPlan().withChildren(planChildren);
-        if (!(plan instanceof PhysicalPlan)) {
-            throw new AnalysisException("Result plan must be PhysicalPlan");
+        try {
+            GroupExpression groupExpression = rootGroup.getLowestCostPlan(physicalProperties).orElseThrow(
+                    () -> new AnalysisException("lowestCostPlans with physicalProperties doesn't exist")).second;
+            List<PhysicalProperties> inputPropertiesList = groupExpression.getInputPropertiesList(physicalProperties);
+
+            List<Plan> planChildren = Lists.newArrayList();
+            for (int i = 0; i < groupExpression.arity(); i++) {
+                planChildren.add(chooseBestPlan(groupExpression.child(i), inputPropertiesList.get(i)));
+            }
+
+            Plan plan = groupExpression.getPlan().withChildren(planChildren);
+            if (!(plan instanceof PhysicalPlan)) {
+                throw new AnalysisException("Result plan must be PhysicalPlan");
+            }
+
+            // TODO: set (logical and physical)properties/statistics/... for physicalPlan.
+            PhysicalPlan physicalPlan = ((PhysicalPlan) plan).withPhysicalPropertiesAndStats(
+                    groupExpression.getOutputProperties(physicalProperties),
+                    groupExpression.getOwnerGroup().getStatistics());
+            return physicalPlan;
+        } catch (Exception e) {
+            String memo = cascadesContext.getMemo().toString();

Review Comment:
   Memo can be very large, I think print it isn't a good choice



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