iamhaseebn opened a new pull request, #24054: URL: https://github.com/apache/datafusion/pull/24054
## Which issue does this PR close? - Closes #22257. ## Rationale for this change PostgreSQL treats an empty regular-expression pattern as a zero-width match at each character boundary. regexp_instr currently returns 0 before compiling an empty pattern, so it diverges from that behavior. The existing start-position mapping also excludes the terminal boundary needed for a match after the final character. ## What changes are included in this PR? - Let the regex implementation evaluate empty patterns instead of returning early. - Map the 1-based start position to UTF-8 byte boundaries including the terminal boundary. - Add regression coverage for empty input, end-of-string and out-of-range starts, N-th matches, multibyte characters, and each supported string-array representation. - Add SQL logic coverage for the PostgreSQL-compatible results. ## Are these changes tested? Yes. The following checks pass: - cargo fmt --all -- --check - cargo clippy --all-targets --all-features -- -D warnings - cargo test -p datafusion-functions - cargo test --profile=ci --test sqllogictests -- regexp_instr.slt - the repository-prescribed extended workspace test suite - cargo test --profile ci -p datafusion-cli ## Are there any user-facing changes? Yes. regexp_instr now returns PostgreSQL-compatible positions for empty patterns, including on empty strings and at the terminal character boundary. This does not change the public API. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
