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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/TreeNode.java:
##########
@@ -241,6 +242,19 @@ default <T> Set<T> 
collectToSet(Predicate<TreeNode<NODE_TYPE>> predicate) {
         return (Set<T>) result.build();
     }
 
+    /**
+     * Collect the nodes that satisfied the predicate firstly.
+     */
+    default <T> List<T> collectFirst(Predicate<TreeNode<NODE_TYPE>> predicate) 
{
+        List<TreeNode<NODE_TYPE>> result = new ArrayList<>();
+        foreach(node -> {

Review Comment:
   maybe we could impl it more efficiently



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java:
##########
@@ -60,15 +63,18 @@
  */
 public abstract class AbstractMaterializedViewAggregateRule extends 
AbstractMaterializedViewRule {
 
-    protected static final Map<Expression, Expression>
-            AGGREGATE_ROLL_UP_EQUIVALENT_FUNCTION_MAP = new HashMap<>();
+    // we only support roll up function which has only one argument currently
+    protected static final List<Pair<Expression, Expression>>
+            AGGREGATE_ROLL_UP_EQUIVALENT_FUNCTION_LIST = new ArrayList<>();

Review Comment:
   `map<Expression, map<Expression, Expression>>` maybe better?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java:
##########
@@ -267,7 +273,7 @@ private Function rollup(AggregateFunction queryFunction,
                 if (!(mvExprShuttled instanceof Function)) {
                     continue;
                 }
-                if (isAggregateFunctionEquivalent(queryFunction, (Function) 
mvExprShuttled)) {
+                if (isAggregateFunctionEquivalent(queryFunction, 
queryFunctionShuttled, (Function) mvExprShuttled)) {

Review Comment:
   add more comment to explain each parameters of function `rollup`, 
`isAggregateFunctionEquivalent` and `extractViewArguments`



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