Bug Report
On a base table (or a materialized copy of a UNION ALL), TiDB correctly returns 0.0. Over a ≥3-way UNION ALL of the same rows (e.g. MOD(sh,4)=0/1/2/3 partitions), the same aggregates return a nonzero value (STDDEV_POP ≈ 443.405). A 2-way UNION ALL still returns 0.0. MySQL 9.7.2 and MariaDB 11.4 return 0.0 for the 4-way form.
1. Minimal reproduce step (Required)
CREATE TABLE u (sh BIGINT UNSIGNED);
INSERT INTO u VALUES
(18446744073709551614),
(18446744073709551613),
(18446744073709551612),
(18446744073709551611),
(18446744073709551610),
(18446744073709551609),
(18446744073709551608),
(18446744073709551607);
SELECT STDDEV_POP(sh) FROM u;
-- 0.0
SELECT STDDEV_POP(sh) FROM (
SELECT sh FROM u WHERE MOD(sh, 4) = 0
UNION ALL SELECT sh FROM u WHERE MOD(sh, 4) = 1
UNION ALL SELECT sh FROM u WHERE MOD(sh, 4) = 2
UNION ALL SELECT sh FROM u WHERE MOD(sh, 4) = 3
) AS x;
-- 443.40500673763256
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
tidb 8.0.11-TiDB-v8.5.0
Bug Report
On a base table (or a materialized copy of a
UNION ALL), TiDB correctly returns0.0. Over a ≥3-wayUNION ALLof the same rows (e.g.MOD(sh,4)=0/1/2/3partitions), the same aggregates return a nonzero value (STDDEV_POP≈443.405). A 2-wayUNION ALLstill returns0.0. MySQL 9.7.2 and MariaDB 11.4 return0.0for the 4-way form.1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
tidb 8.0.11-TiDB-v8.5.0