yashmayya commented on code in PR #13573:
URL: https://github.com/apache/pinot/pull/13573#discussion_r1673732482
##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotAggregateReduceFunctionsRule.java:
##########
@@ -16,21 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.pinot.calcite.sql.fun;
+package org.apache.pinot.calcite.rel.rules;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlNode;
-import org.apache.calcite.sql.fun.SqlCoalesceFunction;
-import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.rules.AggregateReduceFunctionsRule;
+import org.apache.calcite.sql.SqlKind;
/**
- * Pinot supports native COALESCE function, thus no need to create CASE WHEN
conversion.
+ * Pinot customized version of {@link AggregateReduceFunctionsRule} which only
reduce on SUM and AVG.
*/
-public class PinotSqlCoalesceFunction extends SqlCoalesceFunction {
+public class PinotAggregateReduceFunctionsRule extends
AggregateReduceFunctionsRule {
+ public static final PinotAggregateReduceFunctionsRule INSTANCE =
+ new PinotAggregateReduceFunctionsRule(Config.DEFAULT);
+
+ private PinotAggregateReduceFunctionsRule(Config config) {
+ super(config);
+ }
@Override
- public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
- return call;
+ public boolean canReduce(AggregateCall call) {
+ SqlKind kind = call.getAggregation().getKind();
+ return kind == SqlKind.SUM || kind == SqlKind.AVG;
Review Comment:
Ah okay, makes sense now, thanks!
--
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]