somandal commented on code in PR #10799: URL: https://github.com/apache/pinot/pull/10799#discussion_r1204868921
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/utils/AggregationUtils.java: ########## @@ -54,54 +54,92 @@ public static Key extractEmptyKey() { return new Key(new Object[0]); } - private static Object mergeSum(Object left, Object right) { - return ((Number) left).doubleValue() + ((Number) right).doubleValue(); + // TODO: Use the correct type for SUM/MIN/MAX instead of always using double + + @Nullable + private static Object mergeSum(@Nullable Object agg, @Nullable Object value) { + if (agg == null) { + return value; + } + if (value == null) { + return agg; + } + return ((Number) agg).doubleValue() + ((Number) value).doubleValue(); } - private static Object mergeMin(Object left, Object right) { - return Math.min(((Number) left).doubleValue(), ((Number) right).doubleValue()); + @Nullable + private static Object mergeMin(@Nullable Object agg, @Nullable Object value) { + if (agg == null) { + return value; + } + if (value == null) { + return agg; + } + return Math.min(((Number) agg).doubleValue(), ((Number) value).doubleValue()); } - private static Object mergeMax(Object left, Object right) { - return Math.max(((Number) left).doubleValue(), ((Number) right).doubleValue()); + @Nullable + private static Object mergeMax(@Nullable Object agg, @Nullable Object value) { + if (agg == null) { Review Comment: Thanks for getting back on this! So to make sure I understand correctly, when the data is sent from leaf to intermediate, the null values will be correctly set to null in the `List<Object[]>`? Thus making a simple null check like this good enough? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org