Copilot commented on code in PR #56764:
URL: https://github.com/apache/doris/pull/56764#discussion_r2425116609


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/eageraggregation/PushDownAggContext.java:
##########
@@ -0,0 +1,117 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite.eageraggregation;
+
+import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.trees.expressions.Alias;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import 
org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * PushDownAggContext
+ */
+public class PushDownAggContext {
+    private final List<AggregateFunction> aggFunctions;
+    private final List<NamedExpression> groupKeys;
+    private final Map<AggregateFunction, Alias> aliasMap;
+    private final Set<Slot> aggFunctionsInputSlots;
+
+    // the group keys that eventually used to generate aggregation node
+    private final LinkedHashSet<SlotReference> finalGroupKeys = new 
LinkedHashSet<>();
+
+    // cascadesContext is used for normalizeAgg
+    private final CascadesContext cascadesContext;
+
+    /**
+     * constructor
+     */
+    public PushDownAggContext(List<AggregateFunction> aggFunctions,
+            List<NamedExpression> groupKeys,
+            CascadesContext cascadesContext) {
+        this(aggFunctions, groupKeys, null, cascadesContext);
+    }
+
+    /**
+     * constructor
+     */
+    public PushDownAggContext(List<AggregateFunction> aggFunctions,
+            List<NamedExpression> groupKeys, Map<AggregateFunction, Alias> 
aliasMap, CascadesContext cascadesContext) {
+        this.groupKeys = groupKeys;
+        this.aggFunctions = ImmutableList.copyOf(aggFunctions);
+        this.cascadesContext = cascadesContext;
+
+        if (aliasMap == null) {
+            ImmutableMap.Builder<AggregateFunction, Alias> aliasMapBuilder = 
ImmutableMap.builder();
+            for (AggregateFunction aggFunction : this.aggFunctions) {
+                Alias alias = new Alias(aggFunction, aggFunction.getName());
+                aliasMapBuilder.put(aggFunction, alias);
+            }
+            this.aliasMap = aliasMapBuilder.build();
+        } else {
+            this.aliasMap = aliasMap;
+        }
+
+        this.aggFunctionsInputSlots = aggFunctions.stream()
+                .flatMap(aggFunction -> aggFunction.getInputSlots().stream())
+                .filter(Slot.class::isInstance)
+                .collect(ImmutableSet.toImmutableSet());
+    }
+
+    public Map<AggregateFunction, Alias> getAliasMap() {
+        return aliasMap;
+    }
+
+    public List<AggregateFunction> getAggFunctions() {
+        return aggFunctions;
+    }
+
+    public List<NamedExpression> getGroupKeys() {
+        return groupKeys;
+    }
+
+    public PushDownAggContext withGoupKeys(List<NamedExpression> groupKeys) {

Review Comment:
   Corrected spelling of 'withGoupKeys' to 'withGroupKeys'.
   ```suggestion
       public PushDownAggContext withGroupKeys(List<NamedExpression> groupKeys) 
{
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/eageraggregation/PushDownAggregation.java:
##########
@@ -0,0 +1,243 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+

Review Comment:
   The Apache license header is duplicated at the beginning of the file. The 
second copy (lines 18-33) should be removed.
   ```suggestion
   
   ```



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

Reply via email to