aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/testthat/test_sparkSQL.R
diff options
context:
space:
mode:
authorDongjoon Hyun <dongjoon@apache.org>2016-06-20 11:30:26 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-06-20 11:30:26 -0700
commitc44bf137c7ca649e0c504229eb3e6ff7955e9a53 (patch)
treefa7fade42068841c8fb8403b0c7434eefc874e55 /R/pkg/inst/tests/testthat/test_sparkSQL.R
parent36e812d4b695566437c6bac991ef06a0f81fb1c5 (diff)
downloadspark-c44bf137c7ca649e0c504229eb3e6ff7955e9a53.tar.gz
spark-c44bf137c7ca649e0c504229eb3e6ff7955e9a53.tar.bz2
spark-c44bf137c7ca649e0c504229eb3e6ff7955e9a53.zip
[SPARK-16051][R] Add `read.orc/write.orc` to SparkR
## What changes were proposed in this pull request? This issue adds `read.orc/write.orc` to SparkR for API parity. ## How was this patch tested? Pass the Jenkins tests (with new testcases). Author: Dongjoon Hyun <dongjoon@apache.org> Closes #13763 from dongjoon-hyun/SPARK-16051.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-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 ceba0d138e..114fec6e36 100644
--- a/R/pkg/inst/tests/testthat/test_sparkSQL.R
+++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R
@@ -68,6 +68,7 @@ mockLines <- c("{\"name\":\"Michael\"}",
"{\"name\":\"Justin\", \"age\":19}")
jsonPath <- tempfile(pattern = "sparkr-test", fileext = ".tmp")
parquetPath <- tempfile(pattern = "sparkr-test", fileext = ".parquet")
+orcPath <- tempfile(pattern = "sparkr-test", fileext = ".orc")
writeLines(mockLines, jsonPath)
# For test nafunctions, like dropna(), fillna(),...
@@ -1667,6 +1668,25 @@ test_that("mutate(), transform(), rename() and names()", {
detach(airquality)
})
+test_that("read/write ORC files", {
+ df <- read.df(jsonPath, "json")
+
+ # Test write.df and read.df
+ write.df(df, orcPath, "orc", mode = "overwrite")
+ df2 <- read.df(orcPath, "orc")
+ expect_is(df2, "SparkDataFrame")
+ expect_equal(count(df), count(df2))
+
+ # Test write.orc and read.orc
+ orcPath2 <- tempfile(pattern = "orcPath2", fileext = ".orc")
+ write.orc(df, orcPath2)
+ orcDF <- read.orc(orcPath2)
+ expect_is(orcDF, "SparkDataFrame")
+ expect_equal(count(orcDF), count(df))
+
+ unlink(orcPath2)
+})
+
test_that("read/write Parquet files", {
df <- read.df(jsonPath, "json")
# Test write.df and read.df
@@ -2351,5 +2371,6 @@ test_that("enableHiveSupport on SparkSession", {
})
unlink(parquetPath)
+unlink(orcPath)
unlink(jsonPath)
unlink(jsonPathNa)