cecemei commented on code in PR #18307:
URL: https://github.com/apache/druid/pull/18307#discussion_r2224203404
##########
processing/src/main/java/org/apache/druid/query/aggregation/NullableNumericAggregatorFactory.java:
##########
@@ -48,31 +50,44 @@
public abstract class NullableNumericAggregatorFactory<T extends
BaseNullableColumnValueSelector>
extends AggregatorFactory
{
+ /**
+ * If this aggregator does not aggregate any values, it will return this
value.
+ */
+ @Nullable
+ public Number getDefaultValue()
+ {
+ return null;
+ }
Review Comment:
updated this
##########
processing/src/main/java/org/apache/druid/query/aggregation/LongSumAggregatorFactory.java:
##########
@@ -36,12 +36,33 @@ public class LongSumAggregatorFactory extends
SimpleLongAggregatorFactory
{
private final Supplier<byte[]> cacheKey;
+ /**
+ * The initValue is the value that will be returned when the aggregator
doesn't collect any values.
+ * <p>
+ * For example,
+ * <li> the sum(column) should return null when there's no rows in the
segment, thus initValue is null.
+ * <li> the count(column) should return 0 when there's no rows in the
segment, thus initValue is 0.
+ */
+ @Nullable
+ private final Long initValue;
+
+ public LongSumAggregatorFactory(String name, String fieldName)
+ {
+ this(name, fieldName, null, ExprMacroTable.nil(), null);
+ }
+
+ public LongSumAggregatorFactory(String name, String fieldName, String
expression, ExprMacroTable macroTable)
+ {
+ this(name, fieldName, expression, macroTable, null);
+ }
+
@JsonCreator
public LongSumAggregatorFactory(
@JsonProperty("name") String name,
@JsonProperty("fieldName") final String fieldName,
@JsonProperty("expression") @Nullable String expression,
- @JacksonInject ExprMacroTable macroTable
+ @JacksonInject ExprMacroTable macroTable,
+ @JsonProperty("initValue") @Nullable Long initValue
Review Comment:
updated this
--
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]