dylanhz commented on PR #30202: URL: https://github.com/apache/flink/pull/30202#issuecomment-7332467433
> **The new single-stage fallback returns zero variance and standard deviation for two distinct `DOUBLE` group sums.** Duplicate the [new `MathAggFunctionITCase` case](https://github.com/apache/flink/blob/ac8cb172ec4fe7782c49d80d58f7989806265a94/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MathAggFunctionITCase.java#L227-L255), keeping its `TWO_PHASE`, mini-batch size `1`, and SQL. Add the parallelism setting and replace its source rows with: > > .withConfiguration( > ExecutionConfigOptions.TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, 1) > .withSource(ROW(INT(), DOUBLE()), List.of( > Row.of(1, 9007199254740994.0), > Row.of(2, 9007199254740994.0), > Row.of(2, 2.0))) > Set the expected row to `Row.of(1.0, 2.0, 1.0, 1.414214)` for `VAR_POP`, `VAR_SAMP`, `STDDEV_POP`, and `STDDEV_SAMP`. The PR head `ac8cb172` returns four zeroes; the same test passes at base `75a3d070`. > > The new [partial-merge guard](https://github.com/apache/flink/blob/ac8cb172ec4fe7782c49d80d58f7989806265a94/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/AggregateUtil.scala#L933-L950) sends this retracting aggregate through one stage. In [`accumulate`](https://github.com/apache/flink/blob/ac8cb172ec4fe7782c49d80d58f7989806265a94/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/WelfordM2AggFunction.java#L130-L141), the updated mean rounds to the second value before `delta2` is computed, leaving `M2=0`. Could this path preserve the nonzero second moment and cover this input in the SQL test? > > AI assistance: Codex reviewed, tested, and drafted this comment. Thanks for the reproducer. This precision issue is outside the scope of this PR, which addresses incorrect results from two-stage aggregation on retracting streams. -- 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]
