XieJiann commented on code in PR #30440:
URL: https://github.com/apache/doris/pull/30440#discussion_r1469041729
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java:
##########
@@ -438,9 +439,110 @@ private boolean isAggregateFunctionEquivalent(Function
queryFunction, Function v
* actualFunction is bitmap_union(to_bitmap(case when a = 5 then 1 else 2
end))
* after extracting, the return argument is: case when a = 5 then 1 else 2
end
*/
- private List<Expression> extractArguments(Expression functionWithAny,
Function actualFunction) {
+ private static List<Expression> extractArguments(Expression
functionWithAny, Function actualFunction) {
Set<Object> exprSetToRemove = functionWithAny.collectToSet(expr ->
!(expr instanceof Any));
return actualFunction.collectFirst(expr ->
exprSetToRemove.stream().noneMatch(exprToRemove ->
exprToRemove.equals(expr)));
}
+
+ /**
+ * Aggregate expression rewriter which is responsible for rewriting group
by and
+ * aggregate function expression
+ */
+ protected static class AggregateExpressionRewriter
+ extends
DefaultExpressionRewriter<AggregateExpressionRewriteContext> {
+
+ @Override
+ public Expression visitAggregateFunction(AggregateFunction
aggregateFunction,
+ AggregateExpressionRewriteContext rewriteContext) {
+ if (!rewriteContext.isValid()) {
+ return null;
+ }
+ Expression queryFunctionShuttled =
ExpressionUtils.shuttleExpressionWithLineage(
+ aggregateFunction,
+ rewriteContext.getQueryTopPlan());
+ Function rollupAggregateFunction = rollup(aggregateFunction,
queryFunctionShuttled,
+ rewriteContext.getMvExprToMvScanExprQueryBased());
+ if (rollupAggregateFunction == null) {
+ rewriteContext.setValid(false);
+ return null;
+ }
+ return rollupAggregateFunction;
+ }
+
+ @Override
+ public Expression visitSlot(Slot slot,
AggregateExpressionRewriteContext rewriteContext) {
+ if (!rewriteContext.isValid()) {
+ return null;
+ }
+ if
(rewriteContext.getMvExprToMvScanExprQueryBased().containsKey(slot)) {
+ return
rewriteContext.getMvExprToMvScanExprQueryBased().get(slot);
+ }
+ rewriteContext.setValid(false);
+ return null;
+ }
Review Comment:
```suggestion
return originExpr;
}
```
--
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]