Skip to content

Commit

Permalink
[SPARK-10219] [SPARKR] Fix varargsToEnv and add test case
Browse files Browse the repository at this point in the history
cc sun-rui davies

Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu>

Closes apache#8475 from shivaram/varargs-fix.
  • Loading branch information
shivaram committed Aug 27, 2015
1 parent ce97834 commit e936cf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/pkg/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
6 changes: 6 additions & 0 deletions R/pkg/inst/tests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit e936cf8

Please sign in to comment.