You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(SELECT count(1) FROM telemetry as T1 CROSS JOIN telemetry as T2 WHERE T2.created=NOW() AND T2.created='2023-04-14 19:11:51+00' ) INTERSECT (SELECT count(1) FROM telemetry as T1 JOIN telemetry as T2 on T1.created=T2.created JOIN telemetry as T3 ON T2.created=T3.created WHERE T3.created<NOW() )
The buggy query is a bit complex (I have tried to simplify it but it does not happen in simple cases):
The first half is SELECT count(1) FROM telemetry as T1 CROSS JOIN telemetry as T2 WHERE T2.created=NOW() AND T2.created='2023-04-14 19:11:51+00' where the predicate is always False, so the subquery result is 0.
The second half is SELECT count(1) FROM telemetry as T1 JOIN telemetry as T2 on T1.created=T2.created JOIN telemetry as T3 ON T2.created=T3.created WHERE T3.created<NOW() where the predicate is always True, so the subquery result is greater than 0.
The INTERSECT should return an empty result: [], however, it returns [(0,)]
Replacing the first half with (SELECT 0) or the second half with (SELCT 100) does not have this issue.
To reproduce
(SELECT count(1) FROM telemetry as T1 CROSS JOIN telemetry as T2 WHERE T2.created=NOW() AND T2.created='2023-04-14 19:11:51+00' ) INTERSECT (SELECT count(1) FROM telemetry as T1 JOIN telemetry as T2 on T1.created=T2.created JOIN telemetry as T3 ON T2.created=T3.created WHERE T3.created<NOW() )
Expected Behavior
The INTERSECT should return an empty result: [], however, it returns [(0,)]
Describe the bug
Buggy query:
The buggy query is a bit complex (I have tried to simplify it but it does not happen in simple cases):
The first half is
SELECT count(1) FROM telemetry as T1 CROSS JOIN telemetry as T2 WHERE T2.created=NOW() AND T2.created='2023-04-14 19:11:51+00'
where the predicate is always False, so the subquery result is 0.The second half is
SELECT count(1) FROM telemetry as T1 JOIN telemetry as T2 on T1.created=T2.created JOIN telemetry as T3 ON T2.created=T3.created WHERE T3.created<NOW()
where the predicate is always True, so the subquery result is greater than 0.The INTERSECT should return an empty result: [], however, it returns [(0,)]
Replacing the first half with
(SELECT 0)
or the second half with(SELCT 100)
does not have this issue.To reproduce
Expected Behavior
The INTERSECT should return an empty result: [], however, it returns [(0,)]
Environment
Additional context
No response
The text was updated successfully, but these errors were encountered: