You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/04/29 09:44:32 UTC

[spark] branch branch-3.0 updated: [SPARK-29339][R][FOLLOW-UP] Remove requireNamespace1 workaround for arrow

This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 06e1c0d  [SPARK-29339][R][FOLLOW-UP] Remove requireNamespace1 workaround for arrow
06e1c0d is described below

commit 06e1c0d788407af6101bf66d28cd44ca943d7a42
Author: Michael Chirico <mi...@grabtaxi.com>
AuthorDate: Wed Apr 29 18:42:32 2020 +0900

    [SPARK-29339][R][FOLLOW-UP] Remove requireNamespace1 workaround for arrow
    
    ### What changes were proposed in this pull request?
    
    `requireNamespace1` was used to get `SparkR` on CRAN while Suggesting `arrow` while `arrow` was not yet available on CRAN.
    
    ### Why are the changes needed?
    
    Now `arrow` is on CRAN, we can properly use `requireNamespace` without triggering CRAN failures.
    
    ### Does this PR introduce any user-facing change?
    
    No
    
    ### How was this patch tested?
    
    AppVeyor will test, and CRAN check in Jenkins build.
    
    Closes #28387 from MichaelChirico/r-require-arrow.
    
    Authored-by: Michael Chirico <mi...@grabtaxi.com>
    Signed-off-by: HyukjinKwon <gu...@apache.org>
    (cherry picked from commit 226301a6bc9e675f00e0c66ae31bc2d297e3649f)
    Signed-off-by: HyukjinKwon <gu...@apache.org>
---
 R/pkg/R/DataFrame.R | 15 +++++----------
 R/pkg/R/types.R     |  3 +--
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R
index f67f5fd..09e8318 100644
--- a/R/pkg/R/DataFrame.R
+++ b/R/pkg/R/DataFrame.R
@@ -1226,12 +1226,7 @@ setMethod("collect",
               # empty data.frame with 0 columns and 0 rows
               data.frame()
             } else if (useArrow) {
-              requireNamespace1 <- requireNamespace
-              if (requireNamespace1("arrow", quietly = TRUE)) {
-                read_arrow <- get("read_arrow", envir = asNamespace("arrow"), inherits = FALSE)
-                # Arrow drops `as_tibble` since 0.14.0, see ARROW-5190.
-                useAsTibble <- exists("as_tibble", envir = asNamespace("arrow"))
-
+              if (requireNamespace("arrow", quietly = TRUE)) {
                 portAuth <- callJMethod(x@sdf, "collectAsArrowToR")
                 port <- portAuth[[1]]
                 authSecret <- portAuth[[2]]
@@ -1239,10 +1234,10 @@ setMethod("collect",
                   port = port, blocking = TRUE, open = "wb", timeout = connectionTimeout)
                 output <- tryCatch({
                   doServerAuth(conn, authSecret)
-                  arrowTable <- read_arrow(readRaw(conn))
-                  if (useAsTibble) {
-                    as_tibble <- get("as_tibble", envir = asNamespace("arrow"))
-                    as.data.frame(as_tibble(arrowTable), stringsAsFactors = stringsAsFactors)
+                  arrowTable <- arrow::read_arrow(readRaw(conn))
+                  # Arrow drops `as_tibble` since 0.14.0, see ARROW-5190.
+                  if (exists("as_tibble", envir = asNamespace("arrow"))) {
+                    as.data.frame(arrow::as_tibble(arrowTable), stringsAsFactors = stringsAsFactors)
                   } else {
                     as.data.frame(arrowTable, stringsAsFactors = stringsAsFactors)
                   }
diff --git a/R/pkg/R/types.R b/R/pkg/R/types.R
index 5b41f59..5d48a9e 100644
--- a/R/pkg/R/types.R
+++ b/R/pkg/R/types.R
@@ -88,8 +88,7 @@ specialtypeshandle <- function(type) {
 checkSchemaInArrow <- function(schema) {
   stopifnot(inherits(schema, "structType"))
 
-  requireNamespace1 <- requireNamespace
-  if (!requireNamespace1("arrow", quietly = TRUE)) {
+  if (!requireNamespace("arrow", quietly = TRUE)) {
     stop("'arrow' package should be installed.")
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org