Skip to content

Support string and timestamp MODE aggregations - #19489

Open
xiangfu0 wants to merge 8 commits into
apache:masterfrom
xiangfu0:xiangfu0/codex/mode-non-numeric
Open

Support string and timestamp MODE aggregations#19489
xiangfu0 wants to merge 8 commits into
apache:masterfrom
xiangfu0:xiangfu0/codex/mode-non-numeric

Conversation

@xiangfu0

@xiangfu0 xiangfu0 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Extend the existing ModeAggregationFunction to support STRING and TIMESTAMP automatically with ordinary MODE(value) syntax. AggregationFunctionType.inferArguments supplies inferred arguments through the existing single-stage aggregate optimizer and multi-stage aggregate conversion paths. No function-specific optimizer or planner rule is needed. Complete frequency maps survive distributed stages, and timestamp milliseconds remain exact. Numeric MODE retains DOUBLE results and its existing reducers.

STRING and TIMESTAMP support MIN (default) or MAX ties; AVG is rejected. With null handling enabled, nulls are skipped and empty/all-null typed aggregates return null. Scope is grouped/global MODE, shared argument inference, and focused regression tests.

Validation: 79 OSS JVM tests pass: 56 MODE aggregation cases, eight single-stage inference cases, five planner cases, nine distributed query cases, and the existing explain-plan integration test. Coverage includes both physical planners, direct aggregation, grouping sets, and unchanged legacy rewrite options. Formatting, Checkstyle, and license checks pass on affected modules. The extra compiler-warning build could not complete because an unchanged compression dependency references an unavailable org.jetbrains.annotations.NotNull; the standard source build and tests pass.

@xiangfu0
xiangfu0 marked this pull request as ready for review September 7, 2026 09:54
@codecov-commenter

codecov-commenter commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.58525% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.75%. Comparing base (5e05b9c) to head (0904ef9).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
...r/statement/AggregateFunctionRewriteOptimizer.java 60.25% 20 Missing and 11 partials ⚠️
...che/pinot/segment/spi/AggregationFunctionType.java 34.61% 16 Missing and 1 partial ⚠️
.../aggregation/function/ModeAggregationFunction.java 84.88% 7 Missing and 6 partials ⚠️
...apache/pinot/calcite/rel/rules/PinotRuleUtils.java 75.00% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #19489       +/-   ##
=============================================
+ Coverage     39.44%   67.75%   +28.31%     
- Complexity     1429     1430        +1     
=============================================
  Files          3488     3489        +1     
  Lines        224424   224831      +407     
  Branches      35429    35524       +95     
=============================================
+ Hits          88528   152341    +63813     
+ Misses       127912    60435    -67477     
- Partials       7984    12055     +4071     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 67.75% <69.58%> (+28.31%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 67.75% <69.58%> (+28.31%) ⬆️
unittests 67.75% <69.58%> (+28.31%) ⬆️
unittests1 57.83% <69.58%> (?)
unittests2 39.44% <10.59%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants