You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/17 15:00:36 UTC

[GitHub] [arrow] paleolimbot commented on a diff in pull request #14436: ARROW-17460: [R] Don't warn if the new UDF I'm registering is the same as the existing one

paleolimbot commented on code in PR #14436:
URL: https://github.com/apache/arrow/pull/14436#discussion_r997174084


##########
r/R/compute.R:
##########
@@ -379,9 +379,15 @@ register_scalar_function <- function(name, fun, in_type, out_type,
   RegisterScalarUDF(name, scalar_function)
 
   # register with dplyr binding (enables its use in mutate(), filter(), etc.)
+  # extra step to avoid saving this execution environment in the binding,
+  # which eliminates a warning when the same binding is registered twice
+  binding_fun <- function(...) build_expr(name, ...)
+  body(binding_fun)[[2]] <- name

Review Comment:
   I pushed a less cryptic version of this...it's inlining the value of `name` into the function body:
   
   ``` r
   binding_fun <- function(...) build_expr(name, ...)
   str(as.list(body(binding_fun)))
   #> List of 3
   #>  $ : symbol build_expr
   #>  $ : symbol name
   #>  $ : symbol ...
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org