Skip to content

Commit 41e1416

Browse files
felixcheungFelix Cheung
authored andcommitted
[SPARK-16693][SPARKR] Remove methods deprecated
## What changes were proposed in this pull request? Remove deprecated functions which includes: SQLContext/HiveContext stuff sparkR.init jsonFile parquetFile registerTempTable saveAsParquetFile unionAll createExternalTable dropTempTable ## How was this patch tested? jenkins Author: Felix Cheung <[email protected]> Closes apache#22843 from felixcheung/rrddapi.
1 parent d5573c5 commit 41e1416

File tree

9 files changed

+32
-453
lines changed

9 files changed

+32
-453
lines changed

R/pkg/NAMESPACE

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ importFrom("utils", "download.file", "object.size", "packageVersion", "tail", "u
2828

2929
# S3 methods exported
3030
export("sparkR.session")
31-
export("sparkR.init")
32-
export("sparkR.stop")
3331
export("sparkR.session.stop")
32+
export("sparkR.stop")
3433
export("sparkR.conf")
3534
export("sparkR.version")
3635
export("sparkR.uiWebUrl")
@@ -42,9 +41,6 @@ export("sparkR.callJStatic")
4241

4342
export("install.spark")
4443

45-
export("sparkRSQL.init",
46-
"sparkRHive.init")
47-
4844
# MLlib integration
4945
exportMethods("glm",
5046
"spark.glm",
@@ -151,15 +147,13 @@ exportMethods("arrange",
151147
"printSchema",
152148
"randomSplit",
153149
"rbind",
154-
"registerTempTable",
155150
"rename",
156151
"repartition",
157152
"repartitionByRange",
158153
"rollup",
159154
"sample",
160155
"sample_frac",
161156
"sampleBy",
162-
"saveAsParquetFile",
163157
"saveAsTable",
164158
"saveDF",
165159
"schema",
@@ -175,7 +169,6 @@ exportMethods("arrange",
175169
"toJSON",
176170
"transform",
177171
"union",
178-
"unionAll",
179172
"unionByName",
180173
"unique",
181174
"unpersist",
@@ -415,10 +408,8 @@ export("as.DataFrame",
415408
"cacheTable",
416409
"clearCache",
417410
"createDataFrame",
418-
"createExternalTable",
419411
"createTable",
420412
"currentDatabase",
421-
"dropTempTable",
422413
"dropTempView",
423414
"listColumns",
424415
"listDatabases",

R/pkg/R/DataFrame.R

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ setMethod("showDF",
227227
#' show
228228
#'
229229
#' If eager evaluation is enabled and the Spark object is a SparkDataFrame, evaluate the
230-
#' SparkDataFrame and print top rows of the SparkDataFrame, otherwise, print the class
230+
#' SparkDataFrame and print top rows of the SparkDataFrame, otherwise, print the class
231231
#' and type information of the Spark object.
232232
#'
233233
#' @param object a Spark object. Can be a SparkDataFrame, Column, GroupedData, WindowSpec.
@@ -521,32 +521,6 @@ setMethod("createOrReplaceTempView",
521521
invisible(callJMethod(x@sdf, "createOrReplaceTempView", viewName))
522522
})
523523

524-
#' (Deprecated) Register Temporary Table
525-
#'
526-
#' Registers a SparkDataFrame as a Temporary Table in the SparkSession
527-
#' @param x A SparkDataFrame
528-
#' @param tableName A character vector containing the name of the table
529-
#'
530-
#' @seealso \link{createOrReplaceTempView}
531-
#' @rdname registerTempTable-deprecated
532-
#' @name registerTempTable
533-
#' @aliases registerTempTable,SparkDataFrame,character-method
534-
#' @examples
535-
#'\dontrun{
536-
#' sparkR.session()
537-
#' path <- "path/to/file.json"
538-
#' df <- read.json(path)
539-
#' registerTempTable(df, "json_df")
540-
#' new_df <- sql("SELECT * FROM json_df")
541-
#'}
542-
#' @note registerTempTable since 1.4.0
543-
setMethod("registerTempTable",
544-
signature(x = "SparkDataFrame", tableName = "character"),
545-
function(x, tableName) {
546-
.Deprecated("createOrReplaceTempView")
547-
invisible(callJMethod(x@sdf, "createOrReplaceTempView", tableName))
548-
})
549-
550524
#' insertInto
551525
#'
552526
#' Insert the contents of a SparkDataFrame into a table registered in the current SparkSession.
@@ -956,7 +930,6 @@ setMethod("write.orc",
956930
#' path <- "path/to/file.json"
957931
#' df <- read.json(path)
958932
#' write.parquet(df, "/tmp/sparkr-tmp1/")
959-
#' saveAsParquetFile(df, "/tmp/sparkr-tmp2/")
960933
#'}
961934
#' @note write.parquet since 1.6.0
962935
setMethod("write.parquet",
@@ -967,17 +940,6 @@ setMethod("write.parquet",
967940
invisible(handledCallJMethod(write, "parquet", path))
968941
})
969942

970-
#' @rdname write.parquet
971-
#' @name saveAsParquetFile
972-
#' @aliases saveAsParquetFile,SparkDataFrame,character-method
973-
#' @note saveAsParquetFile since 1.4.0
974-
setMethod("saveAsParquetFile",
975-
signature(x = "SparkDataFrame", path = "character"),
976-
function(x, path) {
977-
.Deprecated("write.parquet")
978-
write.parquet(x, path)
979-
})
980-
981943
#' Save the content of SparkDataFrame in a text file at the specified path.
982944
#'
983945
#' Save the content of the SparkDataFrame in a text file at the specified path.
@@ -2762,18 +2724,6 @@ setMethod("union",
27622724
dataFrame(unioned)
27632725
})
27642726

2765-
#' unionAll is deprecated - use union instead
2766-
#' @rdname union
2767-
#' @name unionAll
2768-
#' @aliases unionAll,SparkDataFrame,SparkDataFrame-method
2769-
#' @note unionAll since 1.4.0
2770-
setMethod("unionAll",
2771-
signature(x = "SparkDataFrame", y = "SparkDataFrame"),
2772-
function(x, y) {
2773-
.Deprecated("union")
2774-
union(x, y)
2775-
})
2776-
27772727
#' Return a new SparkDataFrame containing the union of rows, matched by column names
27782728
#'
27792729
#' Return a new SparkDataFrame containing the union of rows in this SparkDataFrame

R/pkg/R/SQLContext.R

Lines changed: 10 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,6 @@ getInternalType <- function(x) {
3737
stop(paste("Unsupported type for SparkDataFrame:", class(x))))
3838
}
3939

40-
#' Temporary function to reroute old S3 Method call to new
41-
#' This function is specifically implemented to remove SQLContext from the parameter list.
42-
#' It determines the target to route the call by checking the parent of this callsite (say 'func').
43-
#' The target should be called 'func.default'.
44-
#' We need to check the class of x to ensure it is SQLContext/HiveContext before dispatching.
45-
#' @param newFuncSig name of the function the user should call instead in the deprecation message
46-
#' @param x the first parameter of the original call
47-
#' @param ... the rest of parameter to pass along
48-
#' @return whatever the target returns
49-
#' @noRd
50-
dispatchFunc <- function(newFuncSig, x, ...) {
51-
# When called with SparkR::createDataFrame, sys.call()[[1]] returns c(::, SparkR, createDataFrame)
52-
callsite <- as.character(sys.call(sys.parent())[[1]])
53-
funcName <- callsite[[length(callsite)]]
54-
f <- get(paste0(funcName, ".default"))
55-
# Strip sqlContext from list of parameters and then pass the rest along.
56-
contextNames <- c("org.apache.spark.sql.SQLContext",
57-
"org.apache.spark.sql.hive.HiveContext",
58-
"org.apache.spark.sql.hive.test.TestHiveContext",
59-
"org.apache.spark.sql.SparkSession")
60-
if (missing(x) && length(list(...)) == 0) {
61-
f()
62-
} else if (class(x) == "jobj" &&
63-
any(grepl(paste(contextNames, collapse = "|"), getClassName.jobj(x)))) {
64-
.Deprecated(newFuncSig, old = paste0(funcName, "(sqlContext...)"))
65-
f(...)
66-
} else {
67-
f(x, ...)
68-
}
69-
}
70-
7140
#' return the SparkSession
7241
#' @noRd
7342
getSparkSession <- function() {
@@ -198,11 +167,10 @@ getDefaultSqlSource <- function() {
198167
#' df4 <- createDataFrame(cars, numPartitions = 2)
199168
#' }
200169
#' @name createDataFrame
201-
#' @method createDataFrame default
202170
#' @note createDataFrame since 1.4.0
203171
# TODO(davies): support sampling and infer type from NA
204-
createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0,
205-
numPartitions = NULL) {
172+
createDataFrame <- function(data, schema = NULL, samplingRatio = 1.0,
173+
numPartitions = NULL) {
206174
sparkSession <- getSparkSession()
207175

208176
if (is.data.frame(data)) {
@@ -285,31 +253,18 @@ createDataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0,
285253
dataFrame(sdf)
286254
}
287255

288-
createDataFrame <- function(x, ...) {
289-
dispatchFunc("createDataFrame(data, schema = NULL)", x, ...)
290-
}
291-
292256
#' @rdname createDataFrame
293257
#' @aliases createDataFrame
294-
#' @method as.DataFrame default
295258
#' @note as.DataFrame since 1.6.0
296-
as.DataFrame.default <- function(data, schema = NULL, samplingRatio = 1.0, numPartitions = NULL) {
259+
as.DataFrame <- function(data, schema = NULL, samplingRatio = 1.0, numPartitions = NULL) {
297260
createDataFrame(data, schema, samplingRatio, numPartitions)
298261
}
299262

300-
#' @param ... additional argument(s).
301-
#' @rdname createDataFrame
302-
#' @aliases as.DataFrame
303-
as.DataFrame <- function(data, ...) {
304-
dispatchFunc("as.DataFrame(data, schema = NULL)", data, ...)
305-
}
306-
307263
#' toDF
308264
#'
309265
#' Converts an RDD to a SparkDataFrame by infer the types.
310266
#'
311267
#' @param x An RDD
312-
#'
313268
#' @rdname SparkDataFrame
314269
#' @noRd
315270
#' @examples
@@ -345,9 +300,8 @@ setMethod("toDF", signature(x = "RDD"),
345300
#' df <- read.json(path, multiLine = TRUE)
346301
#' }
347302
#' @name read.json
348-
#' @method read.json default
349303
#' @note read.json since 1.6.0
350-
read.json.default <- function(path, ...) {
304+
read.json <- function(path, ...) {
351305
sparkSession <- getSparkSession()
352306
options <- varargsToStrEnv(...)
353307
# Allow the user to have a more flexible definition of the text file path
@@ -358,10 +312,6 @@ read.json.default <- function(path, ...) {
358312
dataFrame(sdf)
359313
}
360314

361-
read.json <- function(x, ...) {
362-
dispatchFunc("read.json(path)", x, ...)
363-
}
364-
365315
#' Create a SparkDataFrame from an ORC file.
366316
#'
367317
#' Loads an ORC file, returning the result as a SparkDataFrame.
@@ -388,13 +338,12 @@ read.orc <- function(path, ...) {
388338
#' Loads a Parquet file, returning the result as a SparkDataFrame.
389339
#'
390340
#' @param path path of file to read. A vector of multiple paths is allowed.
391-
#' @param ... additional external data source specific named properties.
341+
#' @param ... additional data source specific named properties.
392342
#' @return SparkDataFrame
393343
#' @rdname read.parquet
394344
#' @name read.parquet
395-
#' @method read.parquet default
396345
#' @note read.parquet since 1.6.0
397-
read.parquet.default <- function(path, ...) {
346+
read.parquet <- function(path, ...) {
398347
sparkSession <- getSparkSession()
399348
options <- varargsToStrEnv(...)
400349
# Allow the user to have a more flexible definition of the Parquet file path
@@ -405,10 +354,6 @@ read.parquet.default <- function(path, ...) {
405354
dataFrame(sdf)
406355
}
407356

408-
read.parquet <- function(x, ...) {
409-
dispatchFunc("read.parquet(...)", x, ...)
410-
}
411-
412357
#' Create a SparkDataFrame from a text file.
413358
#'
414359
#' Loads text files and returns a SparkDataFrame whose schema starts with
@@ -428,9 +373,8 @@ read.parquet <- function(x, ...) {
428373
#' df <- read.text(path)
429374
#' }
430375
#' @name read.text
431-
#' @method read.text default
432376
#' @note read.text since 1.6.1
433-
read.text.default <- function(path, ...) {
377+
read.text <- function(path, ...) {
434378
sparkSession <- getSparkSession()
435379
options <- varargsToStrEnv(...)
436380
# Allow the user to have a more flexible definition of the text file path
@@ -441,10 +385,6 @@ read.text.default <- function(path, ...) {
441385
dataFrame(sdf)
442386
}
443387

444-
read.text <- function(x, ...) {
445-
dispatchFunc("read.text(path)", x, ...)
446-
}
447-
448388
#' SQL Query
449389
#'
450390
#' Executes a SQL query using Spark, returning the result as a SparkDataFrame.
@@ -461,18 +401,13 @@ read.text <- function(x, ...) {
461401
#' new_df <- sql("SELECT * FROM table")
462402
#' }
463403
#' @name sql
464-
#' @method sql default
465404
#' @note sql since 1.4.0
466-
sql.default <- function(sqlQuery) {
405+
sql <- function(sqlQuery) {
467406
sparkSession <- getSparkSession()
468407
sdf <- callJMethod(sparkSession, "sql", sqlQuery)
469408
dataFrame(sdf)
470409
}
471410

472-
sql <- function(x, ...) {
473-
dispatchFunc("sql(sqlQuery)", x, ...)
474-
}
475-
476411
#' Create a SparkDataFrame from a SparkSQL table or view
477412
#'
478413
#' Returns the specified table or view as a SparkDataFrame. The table or view must already exist or
@@ -531,9 +466,8 @@ tableToDF <- function(tableName) {
531466
#' df4 <- read.df(mapTypeJsonPath, "json", stringSchema, multiLine = TRUE)
532467
#' }
533468
#' @name read.df
534-
#' @method read.df default
535469
#' @note read.df since 1.4.0
536-
read.df.default <- function(path = NULL, source = NULL, schema = NULL, na.strings = "NA", ...) {
470+
read.df <- function(path = NULL, source = NULL, schema = NULL, na.strings = "NA", ...) {
537471
if (!is.null(path) && !is.character(path)) {
538472
stop("path should be character, NULL or omitted.")
539473
}
@@ -568,22 +502,13 @@ read.df.default <- function(path = NULL, source = NULL, schema = NULL, na.string
568502
dataFrame(sdf)
569503
}
570504

571-
read.df <- function(x = NULL, ...) {
572-
dispatchFunc("read.df(path = NULL, source = NULL, schema = NULL, ...)", x, ...)
573-
}
574-
575505
#' @rdname read.df
576506
#' @name loadDF
577-
#' @method loadDF default
578507
#' @note loadDF since 1.6.0
579-
loadDF.default <- function(path = NULL, source = NULL, schema = NULL, ...) {
508+
loadDF <- function(path = NULL, source = NULL, schema = NULL, ...) {
580509
read.df(path, source, schema, ...)
581510
}
582511

583-
loadDF <- function(x = NULL, ...) {
584-
dispatchFunc("loadDF(path = NULL, source = NULL, schema = NULL, ...)", x, ...)
585-
}
586-
587512
#' Create a SparkDataFrame representing the database table accessible via JDBC URL
588513
#'
589514
#' Additional JDBC database connection properties can be set (...)

0 commit comments

Comments
 (0)