aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_sparkSQL.R
diff options
context:
space:
mode:
authorFelix Cheung <felixcheung_m@hotmail.com>2016-06-21 13:36:50 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-06-21 13:36:50 -0700
commitdbfdae4e41a900de01b48639d6554d32edbb2e0b (patch)
treee91108581f7ce883c094deafe26bb1bd3cf7f660 /R/pkg/inst/tests/testthat/test_sparkSQL.R
parent918c91954fb46400ce2c5ab066d2ec0ae48dda4a (diff)
downloadspark-dbfdae4e41a900de01b48639d6554d32edbb2e0b.tar.gz
spark-dbfdae4e41a900de01b48639d6554d32edbb2e0b.tar.bz2
spark-dbfdae4e41a900de01b48639d6554d32edbb2e0b.zip
[SPARK-16096][SPARKR] add union and deprecate unionAll
## What changes were proposed in this pull request? add union and deprecate unionAll, separate roxygen2 doc for rbind (since their usage and parameter lists are quite different) `explode` is also deprecated - but seems like replacement is a combination of calls; not sure if we should deprecate it in SparkR, yet. ## How was this patch tested? unit tests, manual checks for r doc Author: Felix Cheung <felixcheung_m@hotmail.com> Closes #13805 from felixcheung/runion.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R8
1 files changed, 6 insertions, 2 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index 7c192fb5a0..9378c7afac 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -1590,7 +1590,7 @@ test_that("isLocal()", {
expect_false(isLocal(df))
})
-test_that("unionAll(), rbind(), except(), and intersect() on a DataFrame", {
+test_that("union(), rbind(), except(), and intersect() on a DataFrame", {
df <- read.json(jsonPath)
lines <- c("{\"name\":\"Bob\", \"age\":24}",
@@ -1600,10 +1600,11 @@ test_that("unionAll(), rbind(), except(), and intersect() on a DataFrame", {
writeLines(lines, jsonPath2)
df2 <- read.df(jsonPath2, "json")
- unioned <- arrange(unionAll(df, df2), df$age)
+ unioned <- arrange(union(df, df2), df$age)
expect_is(unioned, "SparkDataFrame")
expect_equal(count(unioned), 6)
expect_equal(first(unioned)$name, "Michael")
+ expect_equal(count(arrange(suppressWarnings(unionAll(df, df2)), df$age)), 6)
unioned2 <- arrange(rbind(unioned, df, df2), df$age)
expect_is(unioned2, "SparkDataFrame")
@@ -1620,6 +1621,9 @@ test_that("unionAll(), rbind(), except(), and intersect() on a DataFrame", {
expect_equal(count(intersected), 1)
expect_equal(first(intersected)$name, "Andy")
+ # Test base::union is working
+ expect_equal(union(c(1:3), c(3:5)), c(1:5))
+
# Test base::rbind is working
expect_equal(length(rbind(1:4, c = 2, a = 10, 10, deparse.level = 0)), 16)