Skip to content

fix: Propagate NULLs in regexp_count, regexp_instr - #24239

Open
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-regexp-null-handling
Open

fix: Propagate NULLs in regexp_count, regexp_instr#24239
neilconway wants to merge 2 commits into
apache:mainfrom
neilconway:neilc/fix-regexp-null-handling

Conversation

@neilconway

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

regexp_count and regexp_instr should follow the behavior of these functions in PostgreSQL and return NULL when any of their arguments is NULL. The previous behavior was inconsistent: regexp_instr returned NULL for a NULL string or pattern, but otherwise NULLs were treated as a default value, returned a match count of 0, or raised an error, depending on the context.

What changes are included in this PR?

  • Make NULL handling of regexp_count and regexp_instr consistent and match PostgreSQL
  • Update SLTs or add new SLTs / unit tests as necessary

Are these changes tested?

Yes, new tests added and/or existing tests updated when necessary.

Are there any user-facing changes?

Yes: the behavior of these UDFs has changed when called with NULL arguments.

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.48529% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.00%. Comparing base (d5bd10d) to head (7e535f1).

Files with missing lines Patch % Lines
datafusion/functions/src/regex/regexpcount.rs 91.41% 13 Missing and 1 partial ⚠️
datafusion/functions/src/regex/regexpinstr.rs 99.08% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24239      +/-   ##
==========================================
+ Coverage   80.98%   81.00%   +0.01%     
==========================================
  Files        1106     1106              
  Lines      383495   383697     +202     
  Branches   383495   383697     +202     
==========================================
+ Hits       310590   310810     +220     
+ Misses      54572    54551      -21     
- Partials    18333    18336       +3     

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

Inconsistent NULL handling in regexp_count, regexp_instr

2 participants