Uh oh!
There was an error while loading. Please reload this page.
branch-4.1: [Bug](agg) fix wrong is_trivial on min max #61641 - #61702
Merged
Conversation
related with #60228 This pull request addresses a critical bug in the aggregate functions for `min` and `max` when used with nullable columns in streaming aggregation mode. The main issue was that the aggregation state for `min`/`max` was incorrectly treated as "trivial" (safe to zero-initialize), leading to incorrect results for certain types (e.g., numeric and datetime types) when using the streaming aggregation path. The changes clarify the contract for state initialization in `is_trivial()`, update its implementation, and add comprehensive regression tests to prevent similar issues in the future. **Aggregate function state initialization and correctness:** * Updated the documentation for `IAggregateFunction::is_trivial()` to clarify that only aggregate functions whose state can be safely zero-initialized (such as sum/count/avg) should return `true`. Functions like `min`/`max` that require sentinel values must not be treated as trivial. * Fixed the implementation of `AggregateFunctionsSingleValue::is_trivial()` so that only the `any_value` function with fixed-length types returns `true`. `min` and `max` now correctly return `false`, ensuring their state is always properly initialized with sentinel values. **Testing and regression coverage:** * Added extensive regression tests in `agg_min_max_test.cpp` to verify correct behavior of nullable `min`/`max` in streaming aggregation mode for various types, including `Int32`, `Int64`, and `DateTimeV2`. These tests check both non-null and null scenarios and confirm that results are as expected. * Included a test to confirm that `any_value` still works correctly with the trivial path, ensuring that the fix does not break this special case. * Added necessary test includes for nullable and datetime types to support the new tests.
hello-stephen
commented
Mar 25, 2026
Contributor
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
hello-stephen
commented
Mar 25, 2026
Contributor
run buildall |
doris-robot
commented
Mar 25, 2026
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Mar 25, 2026
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
commented
Mar 25, 2026
Contributor
skip buildall |
yiguolei
approved these changes
Mar 25, 2026
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Cherry-picked from #61641