diff options
author | Cheng Lian <lian@databricks.com> | 2016-06-13 15:46:50 -0700 |
---|---|---|
committer | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2016-06-13 15:46:50 -0700 |
commit | ced8d669b359d6465c3bf476af0f68cc4db04a25 (patch) | |
tree | 197e6cce6c5167286ce43dc8facb92ff40a68154 /R/pkg/inst/tests | |
parent | c4b1ad020962c42be804d3a1a55171d9b51b01e7 (diff) | |
download | spark-ced8d669b359d6465c3bf476af0f68cc4db04a25.tar.gz spark-ced8d669b359d6465c3bf476af0f68cc4db04a25.tar.bz2 spark-ced8d669b359d6465c3bf476af0f68cc4db04a25.zip |
[SPARK-15925][SQL][SPARKR] Replaces registerTempTable with createOrReplaceTempView
## What changes were proposed in this pull request?
This PR replaces `registerTempTable` with `createOrReplaceTempView` as a follow-up task of #12945.
## How was this patch tested?
Existing SparkR tests.
Author: Cheng Lian <lian@databricks.com>
Closes #13644 from liancheng/spark-15925-temp-view-for-r.
Diffstat (limited to 'R/pkg/inst/tests')
-rw-r--r-- | R/pkg/inst/tests/testthat/test_sparkSQL.R | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R index 375cb6f588..d1ca3b726f 100644 --- a/R/pkg/inst/tests/testthat/test_sparkSQL.R +++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R @@ -445,7 +445,7 @@ test_that("jsonRDD() on a RDD with json string", { test_that("test cache, uncache and clearCache", { df <- read.json(jsonPath) - registerTempTable(df, "table1") + createOrReplaceTempView(df, "table1") cacheTable("table1") uncacheTable("table1") clearCache() @@ -454,16 +454,17 @@ test_that("test cache, uncache and clearCache", { test_that("test tableNames and tables", { df <- read.json(jsonPath) - registerTempTable(df, "table1") + createOrReplaceTempView(df, "table1") expect_equal(length(tableNames()), 1) df <- tables() expect_equal(count(df), 1) dropTempTable("table1") }) -test_that("registerTempTable() results in a queryable table and sql() results in a new DataFrame", { +test_that( + "createOrReplaceTempView() results in a queryable table and sql() results in a new DataFrame", { df <- read.json(jsonPath) - registerTempTable(df, "table1") + createOrReplaceTempView(df, "table1") newdf <- sql("SELECT * FROM table1 where name = 'Michael'") expect_is(newdf, "SparkDataFrame") expect_equal(count(newdf), 1) @@ -484,13 +485,13 @@ test_that("insertInto() on a registered table", { write.df(df2, parquetPath2, "parquet", "overwrite") dfParquet2 <- read.df(parquetPath2, "parquet") - registerTempTable(dfParquet, "table1") + createOrReplaceTempView(dfParquet, "table1") insertInto(dfParquet2, "table1") expect_equal(count(sql("select * from table1")), 5) expect_equal(first(sql("select * from table1 order by age"))$name, "Michael") dropTempTable("table1") - registerTempTable(dfParquet, "table1") + createOrReplaceTempView(dfParquet, "table1") insertInto(dfParquet2, "table1", overwrite = TRUE) expect_equal(count(sql("select * from table1")), 2) expect_equal(first(sql("select * from table1 order by age"))$name, "Bob") @@ -502,7 +503,7 @@ test_that("insertInto() on a registered table", { test_that("tableToDF() returns a new DataFrame", { df <- read.json(jsonPath) - registerTempTable(df, "table1") + createOrReplaceTempView(df, "table1") tabledf <- tableToDF("table1") expect_is(tabledf, "SparkDataFrame") expect_equal(count(tabledf), 3) |