You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect regex-to-LIKE simplification for literal backslashes #27120
A regex matching a literal backslash is rewritten to a LIKE pattern with different escaping semantics, producing both false positives and false negatives.
CREATE EXTERNAL TABLE regex_input (
id BIGINT, s VARCHAR, p VARCHAR
)
STORED AS CSV LOCATION 'regex.csv'
OPTIONS ('has_header''true');
SELECT
id,
s ~ ('a'|| chr(92) || chr(92) ||'b') AS constant_pattern,
s ~ p AS dynamic_pattern
FROM regex_input
ORDER BY id;
The constant pattern is optimized into LIKE '%a\b%', where the backslash is consumed as a LIKE escape. The dynamic pattern retains the correct regex behavior.
Thanks for the ping. I've hit a CreatePullRequest permission error on this account (looks like I'm at a cap on open PRs), so I won't be able to open one quickly. Please go ahead and take it — no worries on my side. Happy to review or follow up later if useful.
The bad news is that it still happens. The "good" news is that it is not a new regression (it appears to have been introduced in 54). That doesn't mean it shouldn't be fixed but I also don't think we need to treat it as a 56 release blocker.
Version
s = 'a\b'
s = 'ab'
Status
53.0.0
true
false
correct
53.1.0
true
false
correct
54.0.0
false
true
wrong
54.1.0
false
true
wrong
55.0.0
false
true
wrong
55.1.0
false
true
wrong
main
false
true
wrong
SELECT
s,
s ~ ('a'|| chr(92) || chr(92) ||'b') AS matches_regex
FROM (VALUES (arrow_cast('a\b', 'Utf8View')), (arrow_cast('ab', 'Utf8View'))) AS t(s)
ORDER BY s;
Correct output (53.1.0):
+-----+---------------+
| s | matches_regex |
+-----+---------------+
| a\b | true |
| ab | false |
+-----+---------------+
Wrong output (54.0.0 and later, including main):
+-----+---------------+
| s | matches_regex |
+-----+---------------+
| a\b | false |
| ab | true |
+-----+---------------+
Details
andrewlamb@Andrews-MacBook-Pro-3:~$ ~/Software/datafusion-cli/datafusion-cli-53.1.0
DataFusion CLI v53.1.0
> SELECT
s,
s ~ ('a'|| chr(92) || chr(92) ||'b') AS matches_regex
FROM (VALUES (arrow_cast('a\b', 'Utf8View')), (arrow_cast('ab', 'Utf8View'))) AS t(s)
ORDER BY s;
+-----+---------------+
| s | matches_regex |
+-----+---------------+
| a\b|true|| ab |false|
+-----+---------------+
2 row(s) fetched.
Elapsed 0.002 seconds.
>\q
andrewlamb@Andrews-MacBook-Pro-3:~$ ~/Software/datafusion-cli/datafusion-cli-54.0.0
DataFusion CLI v54.0.0
> SELECT
s,
s ~ ('a'|| chr(92) || chr(92) ||'b') AS matches_regex
FROM (VALUES (arrow_cast('a\b', 'Utf8View')), (arrow_cast('ab', 'Utf8View'))) AS t(s)
ORDER BY s;
+-----+---------------+
| s | matches_regex |
+-----+---------------+
| a\b|false|| ab |true|
+-----+---------------+
2 row(s) fetched.
Elapsed 0.002 seconds.
Activity
jonasHanhan commentedon Nov 5, 2026
take
alamb commentedon Nov 5, 2026
This is a blocker for our 56 release. @jonasHanhan do you think you will be able to make a PR quickly?
alamb commentedon Nov 5, 2026
If not, no worries, we can do it too
jonasHanhan commentedon Nov 5, 2026
Thanks for the ping. I've hit a CreatePullRequest permission error on this account (looks like I'm at a cap on open PRs), so I won't be able to open one quickly. Please go ahead and take it — no worries on my side. Happy to review or follow up later if useful.
alamb commentedon Nov 6, 2026
I did some digging. Here is the PR that introduced it:
The bad news is that it still happens. The "good" news is that it is not a new regression (it appears to have been introduced in 54). That doesn't mean it shouldn't be fixed but I also don't think we need to treat it as a 56 release blocker.
s = 'a\b's = 'ab'Correct output (53.1.0):
Wrong output (54.0.0 and later, including main):
Details
lonless9 commentedon Nov 8, 2026
@alamb Thanks for following up on this! 🙏 Hope we can make progress on a minor version.