Skip to content

Dolt returns a wrong result for REGEXP_LIKE across partitions #11550

Description

@Yibo-Dong

What happened

For a legal partitioned aggregate window, Dolt evaluates the disposable REGEXP_LIKE child correctly in the first partition but returns 0 for the same true predicate in the next partition.

Environment

Dolt main (commit c3b5ce3c67f8677ca08a0a58d8c03cdc95bff8b7). MySQL version 8.0.43.

How to reproduce

Run the corresponding SQL in a fresh Dolt repository.

CREATE TABLE t(
  g INT PRIMARY KEY,
  v INT NOT NULL,
  s VARCHAR(8) NOT NULL
);
INSERT INTO t VALUES (0,10,'a'),(1,50,'a');

SELECT g,
       SUM(CASE WHEN REGEXP_LIKE(s,'a') THEN v ELSE 0 END)
         OVER (PARTITION BY g) AS total
FROM t
ORDER BY g;

Expected Result

MySQL 8.0.43's REGEXP_LIKE(expr, pat) returns 1 when expr matches pat,
and a window result is computed independently for the partition containing
each row. The independent exact-INT expected result is:

g  total
0  10
1  50

This uses no ORDER BY, so the legal default frame is the full partition.
The same expectation follows directly from the two one-row partitions and REGEXP_LIKE('a','a') = 1.

Dolt actual

Dolt returned:

g  total
0  10
1  0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcorrectnessWe don't return the same result as MySQLcustomer issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions