diff options
author | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2015-08-26 22:27:31 -0700 |
---|---|---|
committer | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2015-08-26 22:27:31 -0700 |
commit | e936cf8088a06d6aefce44305f3904bbeb17b432 (patch) | |
tree | b9c160e3afca214ca6d6140ca270ae00a9d11aa1 /R/pkg | |
parent | ce97834dc0cc55eece0e909a4061ca6f2123f60d (diff) | |
download | spark-e936cf8088a06d6aefce44305f3904bbeb17b432.tar.gz spark-e936cf8088a06d6aefce44305f3904bbeb17b432.tar.bz2 spark-e936cf8088a06d6aefce44305f3904bbeb17b432.zip |
[SPARK-10219] [SPARKR] Fix varargsToEnv and add test case
cc sun-rui davies
Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
Closes #8475 from shivaram/varargs-fix.
Diffstat (limited to 'R/pkg')
-rw-r--r-- | R/pkg/R/utils.R | 3 | ||||
-rw-r--r-- | R/pkg/inst/tests/test_sparkSQL.R | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/R/pkg/R/utils.R b/R/pkg/R/utils.R index 4f9f4d9cad..3babcb5193 100644 --- a/R/pkg/R/utils.R +++ b/R/pkg/R/utils.R @@ -314,7 +314,8 @@ convertEnvsToList <- function(keys, vals) { # Utility function to capture the varargs into environment object varargsToEnv <- function(...) { - pairs <- as.list(substitute(list(...)))[-1L] + # Based on http://stackoverflow.com/a/3057419/4577954 + pairs <- list(...) env <- new.env() for (name in names(pairs)) { env[[name]] <- pairs[[name]] diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R index 8e22c56824..4b672e115f 100644 --- a/R/pkg/inst/tests/test_sparkSQL.R +++ b/R/pkg/inst/tests/test_sparkSQL.R @@ -1060,6 +1060,12 @@ test_that("parquetFile works with multiple input paths", { parquetDF <- parquetFile(sqlContext, parquetPath, parquetPath2) expect_is(parquetDF, "DataFrame") expect_equal(count(parquetDF), count(df) * 2) + + # Test if varargs works with variables + saveMode <- "overwrite" + mergeSchema <- "true" + parquetPath3 <- tempfile(pattern = "parquetPath3", fileext = ".parquet") + write.df(df, parquetPath2, "parquet", mode = saveMode, mergeSchema = mergeSchema) }) test_that("describe() and summarize() on a DataFrame", { |