Skip to content

Similar queries return different results with different orderings of the where clause #7048

Closed
@algotr34

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:

  1. 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';
  2. 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;
  3. SELECT *,LENGTH(act_symbol) FROM stocks.ohlcv WHERE LENGTH(act_symbol)<5 AND date>"2023-11-01" AND act_symbol='ACHR';
  4. 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:

  1. I get results !
  2. 0 results
  3. 0 results
  4. 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...

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions