aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_sparkSQL.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R18
1 files changed, 13 insertions, 5 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index 199eb2057f..a7259f362e 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -2222,11 +2222,19 @@ test_that("sampleBy() on a DataFrame", {
})
test_that("approxQuantile() on a DataFrame", {
- l <- lapply(c(0:99), function(i) { i })
- df <- createDataFrame(l, "key")
- quantiles <- approxQuantile(df, "key", c(0.5, 0.8), 0.0)
- expect_equal(quantiles[[1]], 50)
- expect_equal(quantiles[[2]], 80)
+ l <- lapply(c(0:99), function(i) { list(i, 99 - i) })
+ df <- createDataFrame(l, list("a", "b"))
+ quantiles <- approxQuantile(df, "a", c(0.5, 0.8), 0.0)
+ expect_equal(quantiles, list(50, 80))
+ quantiles2 <- approxQuantile(df, c("a", "b"), c(0.5, 0.8), 0.0)
+ expect_equal(quantiles2[[1]], list(50, 80))
+ expect_equal(quantiles2[[2]], list(50, 80))
+
+ dfWithNA <- createDataFrame(data.frame(a = c(NA, 30, 19, 11, 28, 15),
+ b = c(-30, -19, NA, -11, -28, -15)))
+ quantiles3 <- approxQuantile(dfWithNA, c("a", "b"), c(0.5), 0.0)
+ expect_equal(quantiles3[[1]], list(28))
+ expect_equal(quantiles3[[2]], list(-15))
})
test_that("SQL error message is returned from JVM", {