Skip to content

fix: accept an empty flags string in regexp_replace - #24987

Merged
jayzhan211 merged 1 commit into
apache:mainfrom
jackylee-ch:fix-regexp-replace-empty-flags
Sep 7, 2026
Merged

fix: accept an empty flags string in regexp_replace#24987
jayzhan211 merged 1 commit into
apache:mainfrom
jackylee-ch:fix-regexp-replace-empty-flags

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A

Rationale for this change

regexp_replace('foobarbaz', 'b..', 'X', '') errors with regex parse error: (?)b instead of returning fooXbaz. regexp_count and regexp_instr accept an empty flags string through compile_regex, and so does Postgres. 'gg' hits the same error, since stripping g leaves an empty flags string.

What changes are included in this PR?

Both call sites omit the (?flags) prefix when no flags remain after g is stripped, matching compile_regex in the same module.

What is the testing strategy for this PR?

Three queries in regexp_replace.slt and two unit tests in regexpreplace.rs. All of them fail on main with repetition operator missing expression and pass with this change.

Are there any user-facing changes?

regexp_replace with an empty flags string now replaces instead of erroring. No API change.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Sep 6, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.67%. Comparing base (5b389eb) to head (2542278).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24987      +/-   ##
==========================================
- Coverage   81.67%   81.67%   -0.01%     
==========================================
  Files        1126     1126              
  Lines      414524   414545      +21     
  Branches   414524   414545      +21     
==========================================
+ Hits       338558   338571      +13     
- Misses      56054    56057       +3     
- Partials    19912    19917       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jayzhan211 jayzhan211 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jackylee-ch 👍🏻

@jayzhan211

Copy link
Copy Markdown
Contributor

I file follow-up issues for similar functions

@jayzhan211
jayzhan211 added this pull request to the merge queue Sep 7, 2026
Merged via the queue into apache:main with commit 57740ca Sep 7, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants