dolthub / dolthub/dolt

Dolt returns a wrong result for REGEXP_LIKE across partitions

Open
#11,550 0 comments 0 reactions 0 assignees View on GitHub
bug correctness customer issue good repro sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

## 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.

```sql
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:

```text
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:

```text
g total
0 10
1 0
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided SQL reproduction in a fresh Dolt repository and compare its partitioned window result with MySQL 8.0.43. Trace the implementation of REGEXP_LIKE inside the partitioned aggregate window path; done means both one-row partitions return totals of 10 and 50.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.