Hi.
I came across a situation where the results from a SELECT query are not the same depending on the order of conditions around “OR”.
I’m running the latest free Docker version(version 25.0.0-202404051521110861-ed9515a8
).
Here is a simple way to replicate:
CREATE VIEW "@dremio".trades AS SELECT * from (values
(cast(1 as bigint), 'p1', cast('2021-07-19' as date), cast(10 as double), 'ec-1', 'ms-7'),
(2 ,'p1', cast('2021-07-19' as date) ,40 ,'ec-1', 'az-2'),
(3 ,'p1', cast('2021-07-20' as date) , 3 ,'ec-1', 'az-2'),
(4 ,'p1', cast('2021-07-20' as date) , 14 ,'ec-1', 'az-4'),
(5 ,'p2', cast('2021-07-20' as date) , 42 ,'ms-4', 'ms-7'),
(6 ,'p3', cast('2021-07-21' as date) , 33 ,'ms-4', 'ms-7')) AS t(id, product, "date", quantity, seller, buyer);
Then the query
SELECT * FROM "@dremio".trades WHERE ((product = 'p1' AND id = 3) OR buyer = 'ms-7')
returns 2 rows (which is wrong).
While the query
SELECT * FROM "@dremio".trades WHERE (buyer = 'ms-7' OR (product = 'p1' AND id = 3))
returns 4 rows (which is correct).