-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Condition pushdown for rand() > value multiply the probabilities #17244
Copy link
Copy link
Closed
Labels
bugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official releasest-acceptedThe issue is in our backlog, ready to takeThe issue is in our backlog, ready to take
Description
Describe the bug
If we pushdown сonditions with rand() function in subquery, we actually multiply the probabilities.
How to reproduce
Clickhouse version 20.12
SELECT count(*)
FROM
(
SELECT number
FROM
(
SELECT number
FROM numbers(1000000)
)
WHERE rand64() < (0.01 * 18446744073709552000.)
)
Query id: 13c8ae5e-ed90-4610-b7c3-8e8d3bf27f12
┌─count()─┐
│ 114 │
└─────────┘
1 rows in set. Elapsed: 0.008 sec. Processed 1.05 million rows, 8.38 MB (136.06 million rows/s., 1.09 GB/s.)
EXPLAIN SYNTAX
SELECT count(*)
FROM
(
SELECT number
FROM
(
SELECT number
FROM numbers(1000000)
)
WHERE rand64() < (0.01 * 18446744073709552000.)
)
Query id: 6036d15a-32ba-4161-a6fe-41eff40af246
┌─explain─────────────────────────────────────────────────┐
│ SELECT count() │
│ FROM │
│ ( │
│ SELECT number │
│ FROM │
│ ( │
│ SELECT number │
│ FROM numbers(1000000) │
│ WHERE rand64() < (0.01 * 18446744073709552000.) │
│ ) │
│ WHERE rand64() < (0.01 * 18446744073709552000.) │
│ ) │
└─────────────────────────────────────────────────────────┘
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugConfirmed user-visible misbehaviour in official releaseConfirmed user-visible misbehaviour in official releasest-acceptedThe issue is in our backlog, ready to takeThe issue is in our backlog, ready to take