diff options
author | Felix Cheung <felixcheung_m@hotmail.com> | 2016-06-20 11:24:41 -0700 |
---|---|---|
committer | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2016-06-20 11:24:41 -0700 |
commit | 36e812d4b695566437c6bac991ef06a0f81fb1c5 (patch) | |
tree | d8d983465410469221e9fd1ce29d929587aac233 /R/pkg/R | |
parent | 9613424898fd2a586156bc4eb48e255749774f20 (diff) | |
download | spark-36e812d4b695566437c6bac991ef06a0f81fb1c5.tar.gz spark-36e812d4b695566437c6bac991ef06a0f81fb1c5.tar.bz2 spark-36e812d4b695566437c6bac991ef06a0f81fb1c5.zip |
[SPARK-16029][SPARKR] SparkR add dropTempView and deprecate dropTempTable
## What changes were proposed in this pull request?
Add dropTempView and deprecate dropTempTable
## How was this patch tested?
unit tests
shivaram liancheng
Author: Felix Cheung <felixcheung_m@hotmail.com>
Closes #13753 from felixcheung/rdroptempview.
Diffstat (limited to 'R/pkg/R')
-rw-r--r-- | R/pkg/R/SQLContext.R | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/R/pkg/R/SQLContext.R b/R/pkg/R/SQLContext.R index 3232241f8a..b0ccc42ff8 100644 --- a/R/pkg/R/SQLContext.R +++ b/R/pkg/R/SQLContext.R @@ -599,13 +599,14 @@ clearCache <- function() { dispatchFunc("clearCache()") } -#' Drop Temporary Table +#' (Deprecated) Drop Temporary Table #' #' Drops the temporary table with the given table name in the catalog. #' If the table has been cached/persisted before, it's also unpersisted. #' #' @param tableName The name of the SparkSQL table to be dropped. -#' @rdname dropTempTable +#' @seealso \link{dropTempView} +#' @rdname dropTempTable-deprecated #' @export #' @examples #' \dontrun{ @@ -619,16 +620,42 @@ clearCache <- function() { #' @method dropTempTable default dropTempTable.default <- function(tableName) { - sparkSession <- getSparkSession() if (class(tableName) != "character") { stop("tableName must be a string.") } - catalog <- callJMethod(sparkSession, "catalog") - callJMethod(catalog, "dropTempView", tableName) + dropTempView(tableName) } dropTempTable <- function(x, ...) { - dispatchFunc("dropTempTable(tableName)", x, ...) + .Deprecated("dropTempView") + dispatchFunc("dropTempView(viewName)", x, ...) +} + +#' Drops the temporary view with the given view name in the catalog. +#' +#' Drops the temporary view with the given view name in the catalog. +#' If the view has been cached before, then it will also be uncached. +#' +#' @param viewName the name of the view to be dropped. +#' @rdname dropTempView +#' @name dropTempView +#' @export +#' @examples +#' \dontrun{ +#' sparkR.session() +#' df <- read.df(path, "parquet") +#' createOrReplaceTempView(df, "table") +#' dropTempView("table") +#' } +#' @note since 2.0.0 + +dropTempView <- function(viewName) { + sparkSession <- getSparkSession() + if (class(viewName) != "character") { + stop("viewName must be a string.") + } + catalog <- callJMethod(sparkSession, "catalog") + callJMethod(catalog, "dropTempView", viewName) } #' Load a SparkDataFrame |