aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests
diff options
context:
space:
mode:
authorYanbo Liang <ybliang8@gmail.com>2016-01-06 12:05:41 +0530
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-01-06 12:05:41 +0530
commitd1fea41363c175a67b97cb7b3fe89f9043708739 (patch)
treeba407c27858e56e92e8e4601138418a3cdde10d4 /R/pkg/inst/tests
parentb3ba1be3b77e42120145252b2730a56f1d55fd21 (diff)
downloadspark-d1fea41363c175a67b97cb7b3fe89f9043708739.tar.gz
spark-d1fea41363c175a67b97cb7b3fe89f9043708739.tar.bz2
spark-d1fea41363c175a67b97cb7b3fe89f9043708739.zip
[SPARK-12393][SPARKR] Add read.text and write.text for SparkR
Add ```read.text``` and ```write.text``` for SparkR. cc sun-rui felixcheung shivaram Author: Yanbo Liang <ybliang8@gmail.com> Closes #10348 from yanboliang/spark-12393.
Diffstat (limited to 'R/pkg/inst/tests')
-rw-r--r--R/pkg/inst/tests/testthat/test_sparkSQL.R21
1 files changed, 21 insertions, 0 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R
index ebe8faa34c..eaf60beda3 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -1497,6 +1497,27 @@ test_that("read/write Parquet files", {
unlink(parquetPath4)
})
+test_that("read/write text files", {
+ # Test write.df and read.df
+ df <- read.df(sqlContext, jsonPath, "text")
+ expect_is(df, "DataFrame")
+ expect_equal(colnames(df), c("value"))
+ expect_equal(count(df), 3)
+ textPath <- tempfile(pattern = "textPath", fileext = ".txt")
+ write.df(df, textPath, "text", mode="overwrite")
+
+ # Test write.text and read.text
+ textPath2 <- tempfile(pattern = "textPath2", fileext = ".txt")
+ write.text(df, textPath2)
+ df2 <- read.text(sqlContext, c(textPath, textPath2))
+ expect_is(df2, "DataFrame")
+ expect_equal(colnames(df2), c("value"))
+ expect_equal(count(df2), count(df) * 2)
+
+ unlink(textPath)
+ unlink(textPath2)
+})
+
test_that("describe() and summarize() on a DataFrame", {
df <- read.json(sqlContext, jsonPath)
stats <- describe(df, "age")