feiniaofeiafei commented on code in PR #56942:
URL: https://github.com/apache/doris/pull/56942#discussion_r2451499951
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExprIdRewriter.java:
##########
@@ -100,7 +105,43 @@ public List<ExpressionPatternMatcher<? extends
Expression>> buildRules() {
lastId = newId;
}
}
- }).toRule(ExpressionRuleType.EXPR_ID_REWRITE_REPLACE)
+ }).toRule(ExpressionRuleType.EXPR_ID_REWRITE_REPLACE),
+ matchesType(VirtualSlotReference.class).thenApply(ctx -> {
+ VirtualSlotReference virtualSlot = ctx.expr;
+ Optional<GroupingScalarFunction> originExpression =
virtualSlot.getOriginExpression();
+ if (!originExpression.isPresent()) {
+ return virtualSlot;
+ }
+ List<Expression> newChildren = new ArrayList<>();
+ List<Expression> oldChildren =
originExpression.get().children();
+ for (Expression child : oldChildren) {
+ newChildren.add(child.accept(new
DefaultExpressionRewriter<Void>() {
+ @Override
+ public Expression
visitSlotReference(SlotReference slot, Void context) {
+ ExprId newId =
replaceMap.get(slot.getExprId());
Review Comment:
these code is repeated, use a function to avoid repeated code may be better.
--
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]