xiangfu0 opened a new pull request, #19991: URL: https://github.com/apache/pinot/pull/19991
## Summary Supports `MODE` on STRING, BOOLEAN and TIMESTAMP inputs. The result has the input's type, and ties are broken with `'MIN'` (default) or `'MAX'`. `'AVG'` is rejected for these types. Stacked on #19986. ## How Both engines rewrite the call to an explicit form, `MODE(expr, 'MIN'|'MAX', 'STRING'|'BOOLEAN'|'TIMESTAMP')`, through the existing rewrite path: - **Single-stage:** `AggregateFunctionRewriteOptimizer`, for STRING (and JSON), BOOLEAN and TIMESTAMP columns. - **Multi-stage:** `PinotAggregateTypeArgumentRewriteRule`, for VARCHAR arguments. BOOLEAN and TIMESTAMP already return their own type in the multi-stage engine, so they are unchanged. `ModeAggregationFunction` reads values as the given type. String counts use an `Object2LongOpenHashMap`, serialized with a new `String2LongMap` object type; BOOLEAN and TIMESTAMP reuse the INT and LONG count maps. Empty input returns NULL. ## Compatibility Single-stage `MODE` on BOOLEAN and TIMESTAMP columns now returns BOOLEAN/TIMESTAMP instead of DOUBLE and rejects `'AVG'`. Mixed versions: servers older than the broker fail the rewritten call with `Mode expects at most 2 arguments, got: 3`. ## Tests - `ModeAggregationFunctionTest`: dictionary and raw inputs, null handling, tie reducers, serialized merges, empty input - `ModeQueriesTest`: optimized aggregation, SV/MV group-by, empty input and `'AVG'` rejection - `AggregateFunctionRewriteOptimizerTest`, `ObjectSerDeUtilsTest` - Plan cases in `AggregatePlans.json`, runtime queries in `UDFAggregates.json` -- 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]
