NobiGo commented on a change in pull request #2447:
URL: https://github.com/apache/calcite/pull/2447#discussion_r671583199
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
##########
@@ -1241,6 +1243,83 @@ public static Expression multiplyDivide(Expression e,
BigDecimal multiplier,
}
}
+ /** Implementor for the {@code MODE} aggregate function. */
+ static class ModeImplementor extends StrictAggImplementor {
+ @Override protected void implementNotNullReset(AggContext info,
+ AggResetContext reset) {
+ // acc[0] = null;
+ reset.currentBlock().add(
+ Expressions.statement(
+ Expressions.assign(reset.accumulator().get(0),
+ Expressions.constant(null))));
+ // acc[1] = new HashMap<>();
+ reset.currentBlock().add(
+ Expressions.statement(
+ Expressions.assign(reset.accumulator().get(1),
+ Expressions.new_(HashMap.class))));
+ // acc[2] = Long.valueOf(0);
+ reset.currentBlock().add(
+ Expressions.statement(
+ Expressions.assign(reset.accumulator().get(2),
+ Expressions.constant(0, Long.class))));
+ }
+
+ @Override protected void implementNotNullAdd(AggContext info,
+ AggAddContext add) {
+ Expression currentArg = add.arguments().get(0);
Review comment:
arguments method just can get the column value. So I don't add a comment
--
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]