Skip to content

fix: count empty regexp matches in regexp_count#22312

Closed
toby-bridges wants to merge 1 commit into
apache:mainfrom
toby-bridges:fix/issue-22267-postgresql-compatibility-regexp-count-sh
Closed

fix: count empty regexp matches in regexp_count#22312
toby-bridges wants to merge 1 commit into
apache:mainfrom
toby-bridges:fix/issue-22267-postgresql-compatibility-regexp-count-sh

Conversation

@toby-bridges
Copy link
Copy Markdown

Summary

  • stop short-circuiting regexp_count when the pattern is an empty string
  • preserve NULL regex handling for scalar inputs while allowing empty patterns to flow through the normal regex counting path
  • add a scalar regression test and a sqllogictest case for SELECT regexp_count('abc', '')

Fixes #22267.

Testing

  • cargo test -p datafusion-functions regexp_count
  • cargo test -p datafusion-sqllogictest --test sqllogictests -- regexp_count.slt
  • cargo fmt --all --check
  • git diff --check

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 17, 2026
@kosiew
Copy link
Copy Markdown
Contributor

kosiew commented May 19, 2026

@toby-bridges,
Thanks for your contribution.

Closing this as it is #22311 already addesses the issue.

@kosiew kosiew closed this May 19, 2026
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.

PostgreSQL compatibility: regexp_count should count empty-pattern matches

2 participants