yashmayya commented on code in PR #18513:
URL: https://github.com/apache/pinot/pull/18513#discussion_r3319902752


##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotAggregateUnionTransposeRule.java:
##########
@@ -0,0 +1,196 @@
+/**
+ * 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.pinot.calcite.rel.rules;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelOptRuleOperand;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.Union;
+import org.apache.calcite.rel.hint.RelHint;
+import org.apache.calcite.rel.logical.LogicalAggregate;
+import org.apache.calcite.rel.logical.LogicalUnion;
+import org.apache.calcite.rel.metadata.RelMdUtil;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rel.rules.TransformationRule;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlAggFunction;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.tools.RelBuilder;
+import org.apache.calcite.tools.RelBuilderFactory;
+import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.mapping.Mapping;
+import org.apache.calcite.util.mapping.MappingType;
+import org.apache.calcite.util.mapping.Mappings;
+
+
+/**
+ * Pinot variant of Calcite's {@code AggregateUnionTransposeRule} that pushes 
an {@link Aggregate} past a non-distinct
+ * {@link Union}.
+ *
+ * <p>Calcite's rule decides which aggregate functions are splittable by 
looking up the function's <i>class</i> in a
+ * small allow-list. Pinot ships its own subclasses of {@link SqlAggFunction} 
(e.g. {@code PinotSumFunction},
+ * {@code PinotMinMaxFunction}) that do not extend Calcite's {@code 
SqlSumAggFunction} or {@code SqlMinMaxAggFunction},
+ * so the upstream rule never fires on Pinot's standard SUM/MIN/MAX. This 
variant matches on {@link SqlKind} instead so
+ * the rule also fires for Pinot's custom aggregate functions that share the 
same semantics.
+ *
+ * <p>Must run in the logical-planning phase (alongside {@code 
AggregateUnionAggregateRule}) before
+ * {@code LogicalAggregate} is rewritten to {@code PinotLogicalAggregate}; the 
operand pattern is fixed to
+ * {@link LogicalAggregate} / {@link LogicalUnion}. The emitted plain {@link 
Aggregate} nodes are subsequently split
+ * into LEAF / FINAL pairs by {@code PinotAggregateExchangeNodeInsertRule}.
+ *
+ * <p>This class is stateless and is safe to share across planners.
+ */

Review Comment:
   Done in 4dfc7ab — converted both Javadocs (class-level and the private 
`transformAggCalls` method) to markdown style. License header left as-is.



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