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


##########
r/R/expression.R:
##########
@@ -210,21 +213,20 @@ build_expr <- function(FUN,
   }
   if (FUN == "%in%") {
     # Special-case %in%, which is different from the Array function name
+    value_set <- Array$create(args[[2]])
+    try(
+      value_set <- cast_or_parse(value_set, args[[1]]$type()),
+      silent = TRUE
+    )
+
     expr <- Expression$create("is_in", args[[1]],
       options = list(
-        # If args[[2]] is already an Arrow object (like a scalar),
-        # this wouldn't work
-        value_set = Array$create(args[[2]]),
+        value_set = value_set,
         skip_nulls = TRUE
       )
     )
   } else {
-    args <- lapply(args, function(x) {
-      if (!inherits(x, "Expression")) {
-        x <- Expression$scalar(x)
-      }
-      x
-    })
+    args <- wrap_scalars(args, FUN)

Review Comment:
   I still think a whitelist is safer, although feel free to make the change. 
The `build_expr()` in the user-defined function code ( 
https://github.com/apache/arrow/blob/master/r/R/compute.R#L384 ) would have to 
change to something approaching the previous behaviour since we have no 
guarantees about those functions.



-- 
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]

Reply via email to