aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/test_sparkSQL.R
diff options
context:
space:
mode:
authorAdrian Zhuang <adrian555@users.noreply.github.com>2015-10-13 10:21:07 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2015-10-13 10:21:07 -0700
commitf7f28ee7a513c262d52cf433d25fbf06df9bd1f1 (patch)
treec117851aa454b56cbd28beef071c0d2c73221c62 /R/pkg/inst/tests/test_sparkSQL.R
parent1e0aba90b9e73834af70d196f7f869b062d98d94 (diff)
downloadspark-f7f28ee7a513c262d52cf433d25fbf06df9bd1f1.tar.gz
spark-f7f28ee7a513c262d52cf433d25fbf06df9bd1f1.tar.bz2
spark-f7f28ee7a513c262d52cf433d25fbf06df9bd1f1.zip
[SPARK-10913] [SPARKR] attach() function support
Bring the change code up to date. Author: Adrian Zhuang <adrian555@users.noreply.github.com> Author: adrian555 <wzhuang@us.ibm.com> Closes #9031 from adrian555/attach2.
Diffstat (limited to 'R/pkg/inst/tests/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/test_sparkSQL.R20
1 files changed, 20 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R
index b599994854..d5509e475d 100644
--- a/R/pkg/inst/tests/test_sparkSQL.R
+++ b/R/pkg/inst/tests/test_sparkSQL.R
@@ -1405,6 +1405,26 @@ test_that("Method as.data.frame as a synonym for collect()", {
expect_equal(as.data.frame(irisDF2), collect(irisDF2))
})
+test_that("attach() on a DataFrame", {
+ df <- jsonFile(sqlContext, jsonPath)
+ expect_error(age)
+ attach(df)
+ expect_is(age, "DataFrame")
+ expected_age <- data.frame(age = c(NA, 30, 19))
+ expect_equal(head(age), expected_age)
+ stat <- summary(age)
+ expect_equal(collect(stat)[5, "age"], "30")
+ age <- age$age + 1
+ expect_is(age, "Column")
+ rm(age)
+ stat2 <- summary(age)
+ expect_equal(collect(stat2)[5, "age"], "30")
+ detach("df")
+ stat3 <- summary(df[, "age"])
+ expect_equal(collect(stat3)[5, "age"], "30")
+ expect_error(age)
+})
+
unlink(parquetPath)
unlink(jsonPath)
unlink(jsonPathNa)