Similar queries return different results with different orderings of the where clause #7048
Closed
Description
Is dolt running mysql or just an emulated mysql? because I get strange behavior from dolt sometimes, on very simple queries.
I am running these sample queries against the database at https://www.dolthub.com/repositories/post-no-preference/stocks
The test queries are:
- SELECT *,LENGTH(o.act_symbol) FROM stocks.ohlcv o WHERE LENGTH(o.act_symbol)<5 AND o.date>"2023-11-01" AND o.act_symbol='ACHR';
- SELECT *,LENGTH(o.act_symbol) FROM stocks.ohlcv o WHERE o.date>"2023-11-01" AND o.act_symbol='ACHR' AND LENGTH(o.act_symbol)<5;
- SELECT *,LENGTH(act_symbol) FROM stocks.ohlcv WHERE LENGTH(act_symbol)<5 AND date>"2023-11-01" AND act_symbol='ACHR';
- SELECT *,LENGTH(act_symbol) FROM stocks.ohlcv WHERE date>"2023-11-01" AND act_symbol='ACHR' AND LENGTH(act_symbol)<5;
Please notice that these 4 queries are actually the same query. And they all should return data!
- Query 1 and 2 are using "o" table alias, and the only difference between them is the position of the checks inside the WHERE clause.
- Query 3 and 4 arent using table alias, and the only difference between them is the position of the checks inside the WHERE clause.
Now, when I run these queries through dbeaver (after loading the server by running: dolt sql-server), i get the following results:
- I get results !
- 0 results
- 0 results
- 0 results
Wtf?
When i try dolt sql -q "(query)", even the first query is getting stuck, and eventually returns no data.
Huh?
I'm guessing that its not a mysql bug... but you will be able to tell me...