dylanhz opened a new pull request, #30202: URL: https://github.com/apache/flink/pull/30202
## What is the purpose of the change Fix incorrect streaming results for `VAR_POP`, `VAR_SAMP`, `STDDEV_POP` and `STDDEV_SAMP` on retracting input. A local mini-batch can insert `10` and retract `20` after an earlier batch inserted `20`. The batch has zero net count, but it changes both the sum and the sum of squares. The current Welford accumulator resets at zero and loses that contribution before the global aggregate can merge it. [FLINK-41179](https://issues.apache.org/jira/browse/FLINK-41179) ## Brief change log - Keep a streaming group or window aggregation in one stage if it would directly merge a Welford accumulator that consumes retractions. - Keep the existing merge-method check. Insert-only aggregations remain eligible for two stages. Retracting `DISTINCT` calls also remain eligible because they merge per-value counts and apply the resulting updates to the inner aggregate. ## Verifying this change - `TwoStageAggregateTest` covers retracting input with mixed ordinary and `DISTINCT` calls, retracting input with only `DISTINCT` calls, and insert-only input. - `WindowAggregateTest` verifies the fallback for a tumbling window over a CDC source. - `MathAggFunctionITCase` executes all four functions over updating group sums. The final sums are `7`, `30` and `8`, for which the population variance rounds to `112.666667`. The three suites passed locally on this commit (175 passed, 27 skipped). Full-repository verification did not complete locally. Two MiniCluster tests encountered a local hostname resolution error and both passed when rerun individually. ## Does this pull request potentially affect one of the following parts? | Area | Impact | | --- | --- | | Dependencies | No | | Public API | No | | Serializers | No | | Runtime per-record code paths | No operator code changes. Affected queries may shuffle more records when local aggregation is disabled. | | Deployment or recovery | Yes for replanned jobs. An affected query can have a different stateful operator topology when restoring from a savepoint. | | S3 file system connector | No | ## Documentation Bug fix for existing SQL functions. No new feature or configuration option. --- ##### Was generative AI tooling used to co-author this PR? - [x] Yes Generated-by: OpenAI Codex (GPT-6) -- 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]
