aboutsummaryrefslogtreecommitdiff
path: root/R/pkg/inst/tests/test_sparkSQL.R
diff options
context:
space:
mode:
authorSun Rui <rui.sun@intel.com>2015-05-12 23:52:30 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2015-05-12 23:52:30 -0700
commitdf9b94a57cbd0e028228059d215b446d59d25ba8 (patch)
tree21fca7d47026df323baaa0f4f84ff38c383cb477 /R/pkg/inst/tests/test_sparkSQL.R
parent208b902257bbfb85bf8cadfc942b7134ad690f8b (diff)
downloadspark-df9b94a57cbd0e028228059d215b446d59d25ba8.tar.gz
spark-df9b94a57cbd0e028228059d215b446d59d25ba8.tar.bz2
spark-df9b94a57cbd0e028228059d215b446d59d25ba8.zip
[SPARK-7482] [SPARKR] Rename some DataFrame API methods in SparkR to match their counterparts in Scala.
Author: Sun Rui <rui.sun@intel.com> Closes #6007 from sun-rui/SPARK-7482 and squashes the following commits: 5c5cf5e [Sun Rui] Implement alias loadDF() as a new function. 3a30c10 [Sun Rui] Rename load()/save() to read.df()/write.df(). Also add loadDF()/saveDF() as aliases. 9f569d6 [Sun Rui] [SPARK-7482][SparkR] Rename some DataFrame API methods in SparkR to match their counterparts in Scala.
Diffstat (limited to 'R/pkg/inst/tests/test_sparkSQL.R')
-rw-r--r--R/pkg/inst/tests/test_sparkSQL.R40
1 files changed, 20 insertions, 20 deletions
diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R
index 99c28830c6..1109e8fdba 100644
--- a/R/pkg/inst/tests/test_sparkSQL.R
+++ b/R/pkg/inst/tests/test_sparkSQL.R
@@ -209,18 +209,18 @@ test_that("registerTempTable() results in a queryable table and sql() results in
})
test_that("insertInto() on a registered table", {
- df <- loadDF(sqlCtx, jsonPath, "json")
- saveDF(df, parquetPath, "parquet", "overwrite")
- dfParquet <- loadDF(sqlCtx, parquetPath, "parquet")
+ df <- read.df(sqlCtx, jsonPath, "json")
+ write.df(df, parquetPath, "parquet", "overwrite")
+ dfParquet <- read.df(sqlCtx, parquetPath, "parquet")
lines <- c("{\"name\":\"Bob\", \"age\":24}",
"{\"name\":\"James\", \"age\":35}")
jsonPath2 <- tempfile(pattern="jsonPath2", fileext=".tmp")
parquetPath2 <- tempfile(pattern = "parquetPath2", fileext = ".parquet")
writeLines(lines, jsonPath2)
- df2 <- loadDF(sqlCtx, jsonPath2, "json")
- saveDF(df2, parquetPath2, "parquet", "overwrite")
- dfParquet2 <- loadDF(sqlCtx, parquetPath2, "parquet")
+ df2 <- read.df(sqlCtx, jsonPath2, "json")
+ write.df(df2, parquetPath2, "parquet", "overwrite")
+ dfParquet2 <- read.df(sqlCtx, parquetPath2, "parquet")
registerTempTable(dfParquet, "table1")
insertInto(dfParquet2, "table1")
@@ -421,12 +421,12 @@ test_that("distinct() on DataFrames", {
expect_true(count(uniques) == 3)
})
-test_that("sampleDF on a DataFrame", {
+test_that("sample on a DataFrame", {
df <- jsonFile(sqlCtx, jsonPath)
- sampled <- sampleDF(df, FALSE, 1.0)
+ sampled <- sample(df, FALSE, 1.0)
expect_equal(nrow(collect(sampled)), count(df))
expect_true(inherits(sampled, "DataFrame"))
- sampled2 <- sampleDF(df, FALSE, 0.1)
+ sampled2 <- sample(df, FALSE, 0.1)
expect_true(count(sampled2) < 3)
# Also test sample_frac
@@ -491,16 +491,16 @@ test_that("column calculation", {
expect_true(count(df2) == 3)
})
-test_that("load() from json file", {
- df <- loadDF(sqlCtx, jsonPath, "json")
+test_that("read.df() from json file", {
+ df <- read.df(sqlCtx, jsonPath, "json")
expect_true(inherits(df, "DataFrame"))
expect_true(count(df) == 3)
})
-test_that("save() as parquet file", {
- df <- loadDF(sqlCtx, jsonPath, "json")
- saveDF(df, parquetPath, "parquet", mode="overwrite")
- df2 <- loadDF(sqlCtx, parquetPath, "parquet")
+test_that("write.df() as parquet file", {
+ df <- read.df(sqlCtx, jsonPath, "json")
+ write.df(df, parquetPath, "parquet", mode="overwrite")
+ df2 <- read.df(sqlCtx, parquetPath, "parquet")
expect_true(inherits(df2, "DataFrame"))
expect_true(count(df2) == 3)
})
@@ -670,7 +670,7 @@ test_that("unionAll(), except(), and intersect() on a DataFrame", {
"{\"name\":\"James\", \"age\":35}")
jsonPath2 <- tempfile(pattern="sparkr-test", fileext=".tmp")
writeLines(lines, jsonPath2)
- df2 <- loadDF(sqlCtx, jsonPath2, "json")
+ df2 <- read.df(sqlCtx, jsonPath2, "json")
unioned <- arrange(unionAll(df, df2), df$age)
expect_true(inherits(unioned, "DataFrame"))
@@ -712,9 +712,9 @@ test_that("mutate() and rename()", {
expect_true(columns(newDF2)[1] == "newerAge")
})
-test_that("saveDF() on DataFrame and works with parquetFile", {
+test_that("write.df() on DataFrame and works with parquetFile", {
df <- jsonFile(sqlCtx, jsonPath)
- saveDF(df, parquetPath, "parquet", mode="overwrite")
+ write.df(df, parquetPath, "parquet", mode="overwrite")
parquetDF <- parquetFile(sqlCtx, parquetPath)
expect_true(inherits(parquetDF, "DataFrame"))
expect_equal(count(df), count(parquetDF))
@@ -722,9 +722,9 @@ test_that("saveDF() on DataFrame and works with parquetFile", {
test_that("parquetFile works with multiple input paths", {
df <- jsonFile(sqlCtx, jsonPath)
- saveDF(df, parquetPath, "parquet", mode="overwrite")
+ write.df(df, parquetPath, "parquet", mode="overwrite")
parquetPath2 <- tempfile(pattern = "parquetPath2", fileext = ".parquet")
- saveDF(df, parquetPath2, "parquet", mode="overwrite")
+ write.df(df, parquetPath2, "parquet", mode="overwrite")
parquetDF <- parquetFile(sqlCtx, parquetPath, parquetPath2)
expect_true(inherits(parquetDF, "DataFrame"))
expect_true(count(parquetDF) == count(df)*2)