aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_sparkSQL.R
diff options
context:
space:
mode:
authorzero323 <zero323@users.noreply.github.com>2017-04-24 10:56:57 -0700
committerFelix Cheung <felixcheung@apache.org>2017-04-24 10:56:57 -0700
commit8a272ddc9d2359a724aa89ae2f8de121a4aa7ac2 (patch)
tree38742432d743167daddcf0ad030b553fe6caf23e /R/pkg/inst/tests/testthat/test_sparkSQL.R
parent90264aced7cfdf265636517b91e5d1324fe60112 (diff)
downloadspark-8a272ddc9d2359a724aa89ae2f8de121a4aa7ac2.tar.gz
spark-8a272ddc9d2359a724aa89ae2f8de121a4aa7ac2.tar.bz2
spark-8a272ddc9d2359a724aa89ae2f8de121a4aa7ac2.zip
[SPARK-20438][R] SparkR wrappers for split and repeatHEADmaster
## What changes were proposed in this pull request? Add wrappers for `o.a.s.sql.functions`: - `split` as `split_string` - `repeat` as `repeat_string` ## How was this patch tested? Existing tests, additional unit tests, `check-cran.sh` Author: zero323 <zero323@users.noreply.github.com> Closes #17729 from zero323/SPARK-20438.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R34
1 files changed, 34 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index bf2093fdc4..c21ba2f1a1 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -1546,6 +1546,40 @@ test_that("string operators", {
expect_equal(collect(select(df3, substring_index(df3$a, ".", 2)))[1, 1], "a.b")
expect_equal(collect(select(df3, substring_index(df3$a, ".", -3)))[1, 1], "b.c.d")
expect_equal(collect(select(df3, translate(df3$a, "bc", "12")))[1, 1], "a.1.2.d")
+
+ l4 <- list(list(a = "a.b@c.d 1\\b"))
+ df4 <- createDataFrame(l4)
+ expect_equal(
+ collect(select(df4, split_string(df4$a, "\\s+")))[1, 1],
+ list(list("a.b@c.d", "1\\b"))
+ )
+ expect_equal(
+ collect(select(df4, split_string(df4$a, "\\.")))[1, 1],
+ list(list("a", "b@c", "d 1\\b"))
+ )
+ expect_equal(
+ collect(select(df4, split_string(df4$a, "@")))[1, 1],
+ list(list("a.b", "c.d 1\\b"))
+ )
+ expect_equal(
+ collect(select(df4, split_string(df4$a, "\\\\")))[1, 1],
+ list(list("a.b@c.d 1", "b"))
+ )
+
+ l5 <- list(list(a = "abc"))
+ df5 <- createDataFrame(l5)
+ expect_equal(
+ collect(select(df5, repeat_string(df5$a, 1L)))[1, 1],
+ "abc"
+ )
+ expect_equal(
+ collect(select(df5, repeat_string(df5$a, 3)))[1, 1],
+ "abcabcabc"
+ )
+ expect_equal(
+ collect(select(df5, repeat_string(df5$a, -1)))[1, 1],
+ ""
+ )
})
test_that("date functions on a DataFrame", {