Skip to content

Fix polars Q29 regex semantics to match REGEXP_REPLACE#978

Merged
rschu1ze merged 1 commit into
mainfrom
fix-polars-q29-regex
Jul 9, 2026
Merged

Fix polars Q29 regex semantics to match REGEXP_REPLACE#978
rschu1ze merged 1 commit into
mainfrom
fix-polars-q29-regex

Conversation

@wudidapaopao

@wudidapaopao wudidapaopao commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The polars translation of Q29 used str.extract, which returns null when the regex does not match, while REGEXP_REPLACE(Referer, pattern, '\1') used by other systems keeps the original string for non-matching rows. This semantic inconsistency may give polars a potential performance benefit on this query.

This replaces str.extract(pattern) with str.replace(pattern, '${1}'), which has the same semantics as REGEXP_REPLACE: the matched string is replaced by capture group 1, and non-matching strings are returned unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wudidapaopao wudidapaopao changed the title polars: fix Q29 regex semantics to match REGEXP_REPLACE Fix polars Q29 regex semantics to match REGEXP_REPLACE Jul 9, 2026
@rschu1ze rschu1ze self-assigned this Jul 9, 2026
@rschu1ze rschu1ze merged commit bace1aa into main Jul 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants