Hi Flink developers, I found a reproducible correctness issue with VAR_SAMP on BIGINT values in Apache Flink 2.3.0.
Environment: Apache Flink 2.3.0 Official Docker image: flink:2.3.0-scala_2.12-java17 Batch runtime mode Local execution with parallelism 1 Minimal reproducer: SET 'execution.runtime-mode' = 'batch'; SELECT VAR_SAMP(x) AS variance_bigint, VAR_SAMP(CAST(x AS DOUBLE)) AS variance_double FROM (VALUES (CAST(0 AS BIGINT)), (CAST(5000000000 AS BIGINT)) ) AS t(x); Actual result: variance_bigint: 9223372036854775807 variance_double: 1.25E19 The BIGINT result silently saturates at Long.MAX_VALUE. The exact sample variance is 1.25E19, which exceeds the BIGINT range. I would expect either a wider result type or an explicit overflow error instead of a silently incorrect value. I searched the existing Flink Jira issues but did not find an exact duplicate. My Apache Jira account request is still pending, so I am discussing the issue here first as recommended. Could you please confirm whether this should be reported as a new Jira issue? If appropriate, I can create the issue once my Jira account is approved. Best regards, Suweiwei
