starocean999 commented on code in PR #37644:
URL: https://github.com/apache/doris/pull/37644#discussion_r1674896199
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java:
##########
@@ -204,7 +204,8 @@ public class Rewriter extends AbstractBatchJobExecutor {
* TODO: group these rules to make sure the
result plan is what we expected.
*/
new CorrelateApplyToUnCorrelateApply(),
- new ApplyToJoin()
+ new ApplyToJoin(),
+ new NormalizeAggregate()
Review Comment:
UnCorrelatedApplyAggregateFilter rule will create new aggregate outputs, and
the later rule CheckPrivileges which inherent from ColumnPruning depends on
NormalizeAggregate. There may be some better way to make it work, but
correctly, use NormalizeAggregate for simplicity.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnCorrelatedApplyAggregateFilter.java:
##########
@@ -97,10 +100,19 @@ public List<Rule> buildRules() {
// pull up correlated filter into apply node
List<NamedExpression> newAggOutput = new
ArrayList<>(agg.getOutputExpressions());
List<Expression> newGroupby =
- Utils.getCorrelatedSlots(correlatedPredicate,
apply.getCorrelationSlot());
+ Utils.getUnCorrelatedExprs(correlatedPredicate,
apply.getCorrelationSlot());
newGroupby.addAll(agg.getGroupByExpressions());
-
newAggOutput.addAll(newGroupby.stream().map(NamedExpression.class::cast)
- .collect(ImmutableList.toImmutableList()));
+ Map<Expression, Slot> unCorrelatedExprToSlot = Maps.newHashMap();
+ newAggOutput.addAll(newGroupby.stream().map(expression -> {
+ if (expression instanceof Slot) {
+ return (NamedExpression) expression;
+ } else {
+ Alias alias = new Alias(expression);
+ unCorrelatedExprToSlot.put(expression, alias.toSlot());
+ return alias;
+ }
+ }).collect(ImmutableList.toImmutableList()));
Review Comment:
done
--
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]