Skip to content

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

Open
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix-regexp-replace-empty-flags
Open

fix: accept an empty flags string in regexp_replace#24987
jackylee-ch wants to merge 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.

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.

2 participants