-
Notifications
You must be signed in to change notification settings - Fork 8.3k
SummingMergeTree yields incorrect results in case of ORDER BY ( func( ) ) #57818
Copy link
Copy link
Closed
Labels
Description
CREATE TABLE test (
d Date,
s UInt64,
cnt UInt64
)
ENGINE = SummingMergeTree()
PARTITION BY toYYYYMMDD(d)
ORDER BY (d,cityHash64(s));
insert into test(d, s, cnt) select '2020-01-01', number%111111, 1 from numbers(1e6);
select (
SELECT uniqExact(s)
FROM test
WHERE (d = '2020-01-01') AND (cityHash64(identity(s)) < 9223372036854775807)) a,
(
SELECT uniqExact(s)
FROM test
WHERE (d = '2020-01-01') AND (cityHash64(s) < 9223372036854775807)) b,
a=b format Pretty;
+-------+-------+--------------+
| a | b | equals(a, b) |
+-------+-------+--------------+
| 55767 | 28773 | 0 | -- expected the same
+-------+-------+--------------+
select sum(cnt) from
(select '2020-01-01', number%111111 s, 1 cnt from numbers(1e6))
where cityHash64(s) < 9223372036854775807
format Pretty
+----------+
| sum(cnt) |
+----------+
| 499825 |
+----------+
select sum(cnt) from test
where cityHash64(identity(s)) < 9223372036854775807
format Pretty;
+----------+
| sum(cnt) |
+----------+
| 501904 | -- wrong, expected 499825
+----------+
select sum(cnt) from test
where cityHash64(s) < 9223372036854775807
format Pretty;
+----------+
| sum(cnt) |
+----------+
| 258958 | -- wrong, expected 499825
+----------+Found during the investigation of Sample By issues.
It seems the issue exists from the beginning (20.8.16) https://fiddle.clickhouse.com/a67e1625-5670-4eec-bf96-bb84def03742
Reactions are currently unavailable