Copilot commented on code in PR #51168:
URL: https://github.com/apache/arrow/pull/51168#discussion_r3943939361
##########
r/R/dplyr-funcs-string.R:
##########
@@ -362,10 +362,14 @@ register_bindings_string_regex <- function() {
arrow_r_string_replace_function <- function(max_replacements) {
function(pattern, replacement, x, ignore.case = FALSE, fixed = FALSE) {
if (length(pattern) != 1) {
- validation_error("`pattern` must be a length 1 character vector")
+ validation_error(
+ "Multiple patterns not supported: `pattern` must be a length 1
character vector"
+ )
}
if (length(replacement) != 1) {
- validation_error("`replacement` must be a length 1 character vector")
+ validation_error(
+ "Multiple replacements not supported: `replacement` must be a length
1 character vector"
+ )
Review Comment:
`arrow_r_string_replace_function()` calls `length(replacement)` without
guarding `missing(replacement)`. For stringr-style calls like
`str_replace_all(x, c("pat" = "rep"))` (named `pattern` with omitted
`replacement`), this will currently surface the generic error "argument
'replacement' is missing" instead of the intended `validation_error()` message.
Consider handling `missing()` explicitly so users always get the informative
Arrow limitation error.
--
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]