Skip to content

Fix grouped MAX for non-positive floating-point values#18300

Merged
JackieTien97 merged 1 commit into
apache:masterfrom
JackieTien97:ty-fix-grouped-max-non-positive-values
Jul 24, 2026
Merged

Fix grouped MAX for non-positive floating-point values#18300
JackieTien97 merged 1 commit into
apache:masterfrom
JackieTien97:ty-fix-grouped-max-non-positive-values

Conversation

@JackieTien97

Copy link
Copy Markdown
Contributor

Description

Fix table-model grouped MAX returning NULL when every FLOAT or DOUBLE
value in a group is zero or negative.

GroupedMaxAccumulator initialized floating-point states with Float.MIN_VALUE
and Double.MIN_VALUE. In Java, those constants are the smallest positive
values, not the most negative values. As a result, non-positive inputs never
initialized the group state, and the final result was emitted as NULL.

MAX_BY was unaffected because its implementation explicitly handles the first
input value.

Changes

  • Initialize grouped floating-point MAX states with negative infinity.
  • Add unit coverage for zero, negative, and negative-infinity values for both
    raw and intermediate inputs.
  • Verify that groups with no input still return NULL.
  • Add a table-model SQL regression test covering the non-stream grouped
    aggregation path.

User impact

Grouped MAX(FLOAT) and MAX(DOUBLE) now return the correct value for groups
whose maximum is non-positive, including all-zero groups.

Validation

mvn clean test -pl iotdb-core/calc-commons \
  -Dtest=GroupedMaxAccumulatorTest

mvn clean verify -Drat.skip=true -DskipUTs \
  -Dit.test=IoTDBTableAggregationNonStreamIT#maxNonPositiveFloatingPointTest \
  -DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false \
  -pl integration-test -am -PTableSimpleIT -P with-integration-tests

The targeted integration test passed and the 37-module clean reactor build
completed successfully.

@JackieTien97
JackieTien97 marked this pull request as ready for review July 24, 2026 08:50
@CritasWang

Copy link
Copy Markdown
Collaborator

I think this PR needs to be updated to 2.0.11

@JackieTien97
JackieTien97 merged commit 939500d into apache:master Jul 24, 2026
40 of 41 checks passed
@JackieTien97
JackieTien97 deleted the ty-fix-grouped-max-non-positive-values branch July 24, 2026 09:05
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