Gosling-dude opened a new pull request, #51197:
URL: https://github.com/apache/arrow/pull/51197
### Rationale for this change
`base::sub()`/`gsub()` and `stringr::str_replace()`/`str_replace_all()` set
the whole
element to `NA` when the replacement is `NA` and the pattern matches. The
Acero
`replace_substring[_regex]` kernels don't support that and splice a literal
`"NA"`
into the string, e.g. `str_replace("one", "o", NA_character_)` returns
`"NAne"`
instead of `NA`.
### What changes are included in this PR?
Special-case an `NA` `replacement` in the shared
`sub`/`gsub`/`str_replace`/`str_replace_all`
binding helper and rewrite it as `if_else(<pattern matches>, NA, x)` using
`match_substring[_regex]`. Covers regex, fixed, and ignore-case patterns.
### Are these changes tested?
Yes — new test in `test-dplyr-funcs-string.R` comparing against base/stringr
for
regex/fixed/ignore-case, empty strings, and `NA` input.
### Are there any user-facing changes?
Bug fix only; `str_replace(x, p, NA)` now returns `NA` on match instead of a
corrupted string.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]