aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests
diff options
context:
space:
mode:
authorYanbo Liang <ybliang8@gmail.com>2016-03-10 17:31:19 -0800
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-03-10 17:31:19 -0800
commit4d535d1f1c19faa43f96433aee8760e37b1690ea (patch)
tree8752d2645c0a54317cd51679f23847698e90eb9f /R/pkg/inst/tests
parentc3a6269ca994a977303a450043a577f435565f4e (diff)
downloadspark-4d535d1f1c19faa43f96433aee8760e37b1690ea.tar.gz
spark-4d535d1f1c19faa43f96433aee8760e37b1690ea.tar.bz2
spark-4d535d1f1c19faa43f96433aee8760e37b1690ea.zip
[SPARK-13389][SPARKR] SparkR support first/last with ignore NAs
## What changes were proposed in this pull request? SparkR support first/last with ignore NAs cc sun-rui felixcheung shivaram ## How was the this patch tested? unit tests Author: Yanbo Liang <ybliang8@gmail.com> Closes #11267 from yanboliang/spark-13389.
Diffstat (limited to 'R/pkg/inst/tests')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R11
1 files changed, 11 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index cad5766812..11a8f12fd5 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -1076,6 +1076,17 @@ test_that("column functions", {
result <- collect(select(df, encode(df$a, "utf-8"), decode(df$c, "utf-8")))
expect_equal(result[[1]][[1]], bytes)
expect_equal(result[[2]], markUtf8("大千世界"))
+
+ # Test first(), last()
+ df <- read.json(sqlContext, jsonPath)
+ expect_equal(collect(select(df, first(df$age)))[[1]], NA)
+ expect_equal(collect(select(df, first(df$age, TRUE)))[[1]], 30)
+ expect_equal(collect(select(df, first("age")))[[1]], NA)
+ expect_equal(collect(select(df, first("age", TRUE)))[[1]], 30)
+ expect_equal(collect(select(df, last(df$age)))[[1]], 19)
+ expect_equal(collect(select(df, last(df$age, TRUE)))[[1]], 19)
+ expect_equal(collect(select(df, last("age")))[[1]], 19)
+ expect_equal(collect(select(df, last("age", TRUE)))[[1]], 19)
})
test_that("column binary mathfunctions", {