XieJiann commented on code in PR #30230:
URL: https://github.com/apache/doris/pull/30230#discussion_r1462684310


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/node/StructInfoNode.java:
##########
@@ -65,24 +67,49 @@ public StructInfoNode(int index, List<HyperGraph> graphs) {
     }
 
     private @Nullable List<Set<Expression>> collectExpressions(Plan plan) {
-        if (plan instanceof LeafPlan) {
-            return ImmutableList.of();
-        }
-        List<Set<Expression>> childExpressions = 
collectExpressions(plan.child(0));
-        if (!isValidNodePlan(plan) || childExpressions == null) {
-            return null;
-        }
-        if (plan instanceof LogicalAggregate) {
-            return ImmutableList.<Set<Expression>>builder()
-                    .add(ImmutableSet.copyOf(plan.getExpressions()))
-                    .add(ImmutableSet.copyOf(((LogicalAggregate<?>) 
plan).getGroupByExpressions()))
-                    .addAll(childExpressions)
-                    .build();
-        }
-        return ImmutableList.<Set<Expression>>builder()
-                .add(ImmutableSet.copyOf(plan.getExpressions()))
-                .addAll(childExpressions)
-                .build();
+
+        Pair<Boolean, Builder<Set<Expression>>> collector = Pair.of(true, 
ImmutableList.builder());
+        plan.accept(new DefaultPlanVisitor<Void, Pair<Boolean, 
ImmutableList.Builder<Set<Expression>>>>() {
+            @Override
+            public Void visitLogicalAggregate(LogicalAggregate<? extends Plan> 
aggregate,
+                    Pair<Boolean, ImmutableList.Builder<Set<Expression>>> 
collector) {
+                if (!collector.key()) {
+                    return null;
+                }
+                
collector.value().add(ImmutableSet.copyOf(aggregate.getExpressions()));
+                
collector.value().add(ImmutableSet.copyOf(((LogicalAggregate<?>) 
plan).getGroupByExpressions()));
+                return super.visit(aggregate, collector);
+            }
+
+            @Override
+            public Void visitLogicalFilter(LogicalFilter<? extends Plan> 
filter,
+                    Pair<Boolean, ImmutableList.Builder<Set<Expression>>> 
collector) {
+                if (!collector.key()) {
+                    return null;
+                }
+                
collector.value().add(ImmutableSet.copyOf(filter.getExpressions()));
+                return super.visit(filter, collector);
+            }
+
+            @Override
+            public Void visitGroupPlan(GroupPlan groupPlan,
+                    Pair<Boolean, ImmutableList.Builder<Set<Expression>>> 
collector) {
+                if (!collector.key()) {
+                    return null;
+                }
+                return 
super.visit(groupPlan.getGroup().getLogicalExpression().getPlan(), collector);

Review Comment:
   
   ```suggestion
                   
groupPlan.getGroup().getLogicalExpression().get(0).getPlan().accept(this, 
collector);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to