From ced8d669b359d6465c3bf476af0f68cc4db04a25 Mon Sep 17 00:00:00 2001 From: Cheng Lian Date: Mon, 13 Jun 2016 15:46:50 -0700 Subject: [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 Closes #13644 from liancheng/spark-15925-temp-view-for-r. --- R/pkg/inst/tests/testthat/test_sparkSQL.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'R/pkg/inst') 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) -- cgit v1.2.3