englefly commented on code in PR #52742:
URL: https://github.com/apache/doris/pull/52742#discussion_r2183961043
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java:
##########
@@ -102,6 +104,22 @@ public List<Rule> buildRules() {
return new LogicalEmptyRelation(
ConnectContext.get().getStatementContext().getNextRelationId(),
union.getOutput());
+ } else if (union.getConstantExprsList().size() == 1) {
+ List<NamedExpression> constantExprs =
union.getConstantExprsList().get(0);
+ ImmutableList.Builder<NamedExpression>
newOneRowRelationOutput
+ =
ImmutableList.builderWithExpectedSize(constantExprs.size());
+ for (int i = 0; i < constantExprs.size(); i++) {
+ NamedExpression setOutput =
union.getOutput().get(i);
+ NamedExpression constantExpr =
constantExprs.get(i);
+ Expression realConstantExpr = constantExpr
instanceof Alias
+ ? ((Alias) constantExpr).child() :
constantExpr;
+ Alias oneRowRelationOutput = new Alias(
Review Comment:
when constantExpr is alias, why construct an alias again?
--
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]