diff options
author | Felix Cheung <felixcheung_m@hotmail.com> | 2016-12-22 20:54:38 -0800 |
---|---|---|
committer | Felix Cheung <felixcheung@apache.org> | 2016-12-22 20:54:38 -0800 |
commit | 17579bda3c114022a0b3889aa4c9188307af75e9 (patch) | |
tree | ee46ade7bd66ab0b97c08073b4094c99806ce2c0 /R/pkg/inst/tests/testthat/test_sparkSQL.R | |
parent | f252cb5d161e064d39cc1ed1d9299307a0636174 (diff) | |
download | spark-17579bda3c114022a0b3889aa4c9188307af75e9.tar.gz spark-17579bda3c114022a0b3889aa4c9188307af75e9.tar.bz2 spark-17579bda3c114022a0b3889aa4c9188307af75e9.zip |
[SPARK-18958][SPARKR] R API toJSON on DataFrame
## What changes were proposed in this pull request?
It would make it easier to integrate with other component expecting row-based JSON format.
This replaces the non-public toJSON RDD API.
## How was this patch tested?
manual, unit tests
Author: Felix Cheung <felixcheung_m@hotmail.com>
Closes #16368 from felixcheung/rJSON.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_sparkSQL.R')
-rw-r--r-- | R/pkg/inst/tests/testthat/test_sparkSQL.R | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R index 4490f31cd8..c3f0310c75 100644 --- a/R/pkg/inst/tests/testthat/test_sparkSQL.R +++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R @@ -1689,12 +1689,13 @@ test_that("join(), crossJoin() and merge() on a DataFrame", { unlink(jsonPath3) }) -test_that("toJSON() returns an RDD of the correct values", { - df <- read.json(jsonPath) - testRDD <- toJSON(df) - expect_is(testRDD, "RDD") - expect_equal(getSerializedMode(testRDD), "string") - expect_equal(collectRDD(testRDD)[[1]], mockLines[1]) +test_that("toJSON() on DataFrame", { + df <- as.DataFrame(cars) + df_json <- toJSON(df) + expect_is(df_json, "SparkDataFrame") + expect_equal(colnames(df_json), c("value")) + expect_equal(head(df_json, 1), + data.frame(value = "{\"speed\":4.0,\"dist\":2.0}", stringsAsFactors = FALSE)) }) test_that("showDF()", { |