aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/test_sparkSQL.R
diff options
context:
space:
mode:
authorHossein <hossein@databricks.com>2015-07-31 19:24:00 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2015-07-31 19:24:44 -0700
commit712f5b7a9ab52c26e3d086629633950ec2fb7afc (patch)
tree65f4c16244a8bc0beb6521384e11884e4f8e114b /R/pkg/inst/tests/test_sparkSQL.R
parent8cb415a4b9bc1f82127ccce4a5579d433f4e8f83 (diff)
downloadspark-712f5b7a9ab52c26e3d086629633950ec2fb7afc.tar.gz
spark-712f5b7a9ab52c26e3d086629633950ec2fb7afc.tar.bz2
spark-712f5b7a9ab52c26e3d086629633950ec2fb7afc.zip
[SPARK-9318] [SPARK-9320] [SPARKR] Aliases for merge and summary functions on DataFrames
This PR adds synonyms for ```merge``` and ```summary``` in SparkR DataFrame API. cc shivaram Author: Hossein <hossein@databricks.com> Closes #7806 from falaki/SPARK-9320 and squashes the following commits: 72600f7 [Hossein] Updated docs 92a6e75 [Hossein] Fixed merge generic signature issue 4c2b051 [Hossein] Fixing naming with mllib summary 0f3a64c [Hossein] Added ... to generic for merge 30fbaf8 [Hossein] Merged master ae1a4cf [Hossein] Merge branch 'master' into SPARK-9320 e8eb86f [Hossein] Add a generic for merge fc01f2d [Hossein] Added unit test 8d92012 [Hossein] Added merge as an alias for join 5b8bedc [Hossein] Added unit test 632693d [Hossein] Added summary as an alias for describe for DataFrame
Diffstat (limited to 'R/pkg/inst/tests/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/test_sparkSQL.R14
1 files changed, 12 insertions, 2 deletions
diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R
index 9faee8d59c..7377fc8f1c 100644
--- a/R/pkg/inst/tests/test_sparkSQL.R
+++ b/R/pkg/inst/tests/test_sparkSQL.R
@@ -765,7 +765,7 @@ test_that("filter() on a DataFrame", {
expect_equal(count(filtered6), 2)
})
-test_that("join() on a DataFrame", {
+test_that("join() and merge() on a DataFrame", {
df <- jsonFile(sqlContext, jsonPath)
mockLines2 <- c("{\"name\":\"Michael\", \"test\": \"yes\"}",
@@ -794,6 +794,12 @@ test_that("join() on a DataFrame", {
expect_equal(names(joined4), c("newAge", "name", "test"))
expect_equal(count(joined4), 4)
expect_equal(collect(orderBy(joined4, joined4$name))$newAge[3], 24)
+
+ merged <- select(merge(df, df2, df$name == df2$name, "outer"),
+ alias(df$age + 5, "newAge"), df$name, df2$test)
+ expect_equal(names(merged), c("newAge", "name", "test"))
+ expect_equal(count(merged), 4)
+ expect_equal(collect(orderBy(merged, joined4$name))$newAge[3], 24)
})
test_that("toJSON() returns an RDD of the correct values", {
@@ -899,7 +905,7 @@ test_that("parquetFile works with multiple input paths", {
expect_equal(count(parquetDF), count(df) * 2)
})
-test_that("describe() on a DataFrame", {
+test_that("describe() and summarize() on a DataFrame", {
df <- jsonFile(sqlContext, jsonPath)
stats <- describe(df, "age")
expect_equal(collect(stats)[1, "summary"], "count")
@@ -908,6 +914,10 @@ test_that("describe() on a DataFrame", {
stats <- describe(df)
expect_equal(collect(stats)[4, "name"], "Andy")
expect_equal(collect(stats)[5, "age"], "30")
+
+ stats2 <- summary(df)
+ expect_equal(collect(stats2)[4, "name"], "Andy")
+ expect_equal(collect(stats2)[5, "age"], "30")
})
test_that("dropna() on a DataFrame", {