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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java:
##########
@@ -51,11 +51,18 @@ public List<Rule> buildRules() {
         return ImmutableList.of(
             // join->empty
             logicalJoin(any(), any())
-                .when(this::hasEmptyRelationChild)
-                .when(this::canReplaceJoinByEmptyRelation)
-                .then(join -> new LogicalEmptyRelation(
-                    
ConnectContext.get().getStatementContext().getNextRelationId(),
-                    join.getOutput()))
+                // .when(this::hasEmptyRelationChild)
+                // .when(this::canReplaceJoinByEmptyRelation)

Review Comment:
   remove useless code



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java:
##########
@@ -51,11 +51,18 @@ public List<Rule> buildRules() {
         return ImmutableList.of(
             // join->empty
             logicalJoin(any(), any())
-                .when(this::hasEmptyRelationChild)
-                .when(this::canReplaceJoinByEmptyRelation)
-                .then(join -> new LogicalEmptyRelation(
-                    
ConnectContext.get().getStatementContext().getNextRelationId(),
-                    join.getOutput()))
+                // .when(this::hasEmptyRelationChild)
+                // .when(this::canReplaceJoinByEmptyRelation)
+                .then(join -> {
+                            if (hasEmptyRelationChild(join) && 
canReplaceJoinByEmptyRelation(join)
+                                    || bothChildrenEmpty(join)) {

Review Comment:
   use when for better performance



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java:
##########
@@ -68,7 +75,13 @@ public List<Rule> buildRules() {
                     
ConnectContext.get().getStatementContext().getNextRelationId(),
                     agg.getOutput())
                 ).toRule(RuleType.ELIMINATE_AGG_ON_EMPTYRELATION),
-
+            // proj->empty
+            logicalProject(logicalEmptyRelation())
+                    .then(project ->

Review Comment:
   use `thenApply(ctx -> {ctx.statementContext})` for better performance



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