HyukjinKwon commented on a change in pull request #23787: [SPARK-26830][SQL][R] 
Vectorized R dapply() implementation
URL: https://github.com/apache/spark/pull/23787#discussion_r259601935
 
 

 ##########
 File path: R/pkg/R/DataFrame.R
 ##########
 @@ -1437,6 +1437,29 @@ dapplyInternal <- function(x, func, schema) {
     schema <- structType(schema)
   }
 
+  arrowEnabled <- sparkR.conf("spark.sql.execution.arrow.enabled")[[1]] == 
"true"
+  if (arrowEnabled) {
+    requireNamespace1 <- requireNamespace
+    if (!requireNamespace1("arrow", quietly = TRUE)) {
+      stop("'arrow' package should be installed.")
+    }
+    # Currenty Arrow optimization does not support raw for now.
+    # Also, it does not support explicit float type set by users.
+    if (inherits(schema, "structType")) {
+      if (any(sapply(schema$fields(), function(x) x$dataType.toString() == 
"FloatType"))) {
+        stop("Arrow optimization with dapply do not support FloatType yet.")
+      }
+      if (any(sapply(schema$fields(), function(x) x$dataType.toString() == 
"BinaryType"))) {
+        stop("Arrow optimization with dapply do not support BinaryType yet.")
+      }
+    } else if (is.null(schema)) {
+      stop(paste0("Arrow optimization does not support 'dapplyCollect' yet. 
Please use ",
+                  "'collect' and 'dapply' APIs instead."))
 
 Review comment:
   Yes, actually that's why I didn't implemented yet .. as we discussed in the 
JIRA that targets `gapplyCollect`.
   
   I am not very sure about that too - I thought promoting Arrow optimization 
might be a good idea although indeed it's not exactly same since 
`dapplyCollect` can omit schema whereas `dapply` requires it.
   
   Since the message says `Arrow optimization does not support ...`, I roughly 
guess users would disable it too if they cannot use `collect` and `dapply` 
later.
   
   I currently think it's okay only to say Arrow optimization as an alternative 
but I am willing to note to disable Arrow optimization to use `dapplyCollect` 
if you feel kind of strongly about it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to