Fix grouped MAX for non-positive floating-point values - #18300
Merged
JackieTien97 merged 1 commit intoJul 24, 2026
Merged
Conversation
JackieTien97
marked this pull request as ready for review
July 24, 2026 08:50
CritasWang
approved these changes
Jul 24, 2026
Collaborator
|
I think this PR needs to be updated to 2.0.11 |
PDGGK
added a commit
to PDGGK/iotdb-extras
that referenced
this pull request
Jul 25, 2026
The milliseconds aggregation path projected MAX over the numeric COALESCE expression. IoTDB's grouped max accumulator seeds FLOAT/DOUBLE state with Float/Double.MIN_VALUE -- the smallest positive value, not the most negative one -- and only marks a group initialized when value >= state, so a bucket whose numeric maximum is zero or negative comes back NULL. This DAO reads a NULL aggregate as an empty bucket and skips it, so a MAX downsampling query over, for example, a sub-zero sensor silently lost whole buckets instead of failing. Project -MIN(-x) instead: the grouped min accumulator seeds with MAX_VALUE and is not affected, and IEEE-754 negation is exact, so the result is identical over finite values on servers with and without the upstream fix. The projection is shared with the calendar path, whose non-grouped accumulators track an explicit initialized flag rather than a sentinel, so the substitution is exact there too and an empty bucket still yields NULL. The long and string channels are already correct and keep using MAX. Verified against apache/iotdb 2.0.8 and 2.0.10 containers. See apache/iotdb#18300, fixed on master but not yet in a released version. Signed-off-by: Zihan Dai <99155080+PDGGK@users.noreply.github.com>
3 tasks
CritasWang
pushed a commit
to apache/iotdb-extras
that referenced
this pull request
Aug 3, 2026
The milliseconds aggregation path projected MAX over the numeric COALESCE expression. IoTDB's grouped max accumulator seeds FLOAT/DOUBLE state with Float/Double.MIN_VALUE -- the smallest positive value, not the most negative one -- and only marks a group initialized when value >= state, so a bucket whose numeric maximum is zero or negative comes back NULL. This DAO reads a NULL aggregate as an empty bucket and skips it, so a MAX downsampling query over, for example, a sub-zero sensor silently lost whole buckets instead of failing. Project -MIN(-x) instead: the grouped min accumulator seeds with MAX_VALUE and is not affected, and IEEE-754 negation is exact, so the result is identical over finite values on servers with and without the upstream fix. The projection is shared with the calendar path, whose non-grouped accumulators track an explicit initialized flag rather than a sentinel, so the substitution is exact there too and an empty bucket still yields NULL. The long and string channels are already correct and keep using MAX. Verified against apache/iotdb 2.0.8 and 2.0.10 containers. See apache/iotdb#18300, fixed on master but not yet in a released version. Signed-off-by: Zihan Dai <99155080+PDGGK@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix table-model grouped
MAXreturningNULLwhen everyFLOATorDOUBLEvalue in a group is zero or negative.
GroupedMaxAccumulatorinitialized floating-point states withFloat.MIN_VALUEand
Double.MIN_VALUE. In Java, those constants are the smallest positivevalues, 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_BYwas unaffected because its implementation explicitly handles the firstinput value.
Changes
MAXstates with negative infinity.raw and intermediate inputs.
NULL.aggregation path.
User impact
Grouped
MAX(FLOAT)andMAX(DOUBLE)now return the correct value for groupswhose 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-testsThe targeted integration test passed and the 37-module clean reactor build
completed successfully.