BiteTheDDDDt opened a new pull request, #61641: URL: https://github.com/apache/doris/pull/61641
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. -- 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]
