Skip to content

Commit ca545f7

Browse files
committed
[SPARK-25821][SQL] Remove SQLContext methods deprecated in 1.4
## What changes were proposed in this pull request? Remove SQLContext methods deprecated in 1.4 ## How was this patch tested? Existing tests. Closes #22815 from srowen/SPARK-25821. Authored-by: Sean Owen <[email protected]> Signed-off-by: Sean Owen <[email protected]>
1 parent d325ffb commit ca545f7

File tree

5 files changed

+8
-369
lines changed

5 files changed

+8
-369
lines changed

R/pkg/NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,11 @@ export("as.DataFrame",
420420
"currentDatabase",
421421
"dropTempTable",
422422
"dropTempView",
423-
"jsonFile",
424423
"listColumns",
425424
"listDatabases",
426425
"listFunctions",
427426
"listTables",
428427
"loadDF",
429-
"parquetFile",
430428
"read.df",
431429
"read.jdbc",
432430
"read.json",

R/pkg/R/SQLContext.R

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ setMethod("toDF", signature(x = "RDD"),
343343
#' path <- "path/to/file.json"
344344
#' df <- read.json(path)
345345
#' df <- read.json(path, multiLine = TRUE)
346-
#' df <- jsonFile(path)
347346
#' }
348347
#' @name read.json
349348
#' @method read.json default
@@ -363,51 +362,6 @@ read.json <- function(x, ...) {
363362
dispatchFunc("read.json(path)", x, ...)
364363
}
365364

366-
#' @rdname read.json
367-
#' @name jsonFile
368-
#' @method jsonFile default
369-
#' @note jsonFile since 1.4.0
370-
jsonFile.default <- function(path) {
371-
.Deprecated("read.json")
372-
read.json(path)
373-
}
374-
375-
jsonFile <- function(x, ...) {
376-
dispatchFunc("jsonFile(path)", x, ...)
377-
}
378-
379-
#' JSON RDD
380-
#'
381-
#' Loads an RDD storing one JSON object per string as a SparkDataFrame.
382-
#'
383-
#' @param sqlContext SQLContext to use
384-
#' @param rdd An RDD of JSON string
385-
#' @param schema A StructType object to use as schema
386-
#' @param samplingRatio The ratio of simpling used to infer the schema
387-
#' @return A SparkDataFrame
388-
#' @noRd
389-
#' @examples
390-
#'\dontrun{
391-
#' sparkR.session()
392-
#' rdd <- texFile(sc, "path/to/json")
393-
#' df <- jsonRDD(sqlContext, rdd)
394-
#'}
395-
396-
# TODO: remove - this method is no longer exported
397-
# TODO: support schema
398-
jsonRDD <- function(sqlContext, rdd, schema = NULL, samplingRatio = 1.0) {
399-
.Deprecated("read.json")
400-
rdd <- serializeToString(rdd)
401-
if (is.null(schema)) {
402-
read <- callJMethod(sqlContext, "read")
403-
# samplingRatio is deprecated
404-
sdf <- callJMethod(read, "json", callJMethod(getJRDD(rdd), "rdd"))
405-
dataFrame(sdf)
406-
} else {
407-
stop("not implemented")
408-
}
409-
}
410-
411365
#' Create a SparkDataFrame from an ORC file.
412366
#'
413367
#' Loads an ORC file, returning the result as a SparkDataFrame.
@@ -434,6 +388,7 @@ read.orc <- function(path, ...) {
434388
#' Loads a Parquet file, returning the result as a SparkDataFrame.
435389
#'
436390
#' @param path path of file to read. A vector of multiple paths is allowed.
391+
#' @param ... additional external data source specific named properties.
437392
#' @return SparkDataFrame
438393
#' @rdname read.parquet
439394
#' @name read.parquet
@@ -454,20 +409,6 @@ read.parquet <- function(x, ...) {
454409
dispatchFunc("read.parquet(...)", x, ...)
455410
}
456411

457-
#' @param ... argument(s) passed to the method.
458-
#' @rdname read.parquet
459-
#' @name parquetFile
460-
#' @method parquetFile default
461-
#' @note parquetFile since 1.4.0
462-
parquetFile.default <- function(...) {
463-
.Deprecated("read.parquet")
464-
read.parquet(unlist(list(...)))
465-
}
466-
467-
parquetFile <- function(x, ...) {
468-
dispatchFunc("parquetFile(...)", x, ...)
469-
}
470-
471412
#' Create a SparkDataFrame from a text file.
472413
#'
473414
#' Loads text files and returns a SparkDataFrame whose schema starts with

R/pkg/tests/fulltests/test_sparkSQL.R

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,10 @@ test_that("read/write json files", {
628628
jsonPath3 <- tempfile(pattern = "jsonPath3", fileext = ".json")
629629
write.json(df, jsonPath3)
630630

631-
# Test read.json()/jsonFile() works with multiple input paths
631+
# Test read.json() works with multiple input paths
632632
jsonDF1 <- read.json(c(jsonPath2, jsonPath3))
633633
expect_is(jsonDF1, "SparkDataFrame")
634634
expect_equal(count(jsonDF1), 6)
635-
# Suppress warnings because jsonFile is deprecated
636-
jsonDF2 <- suppressWarnings(jsonFile(c(jsonPath2, jsonPath3)))
637-
expect_is(jsonDF2, "SparkDataFrame")
638-
expect_equal(count(jsonDF2), 6)
639635

640636
unlink(jsonPath2)
641637
unlink(jsonPath3)
@@ -655,20 +651,6 @@ test_that("read/write json files - compression option", {
655651
unlink(jsonPath)
656652
})
657653

658-
test_that("jsonRDD() on a RDD with json string", {
659-
sqlContext <- suppressWarnings(sparkRSQL.init(sc))
660-
rdd <- parallelize(sc, mockLines)
661-
expect_equal(countRDD(rdd), 3)
662-
df <- suppressWarnings(jsonRDD(sqlContext, rdd))
663-
expect_is(df, "SparkDataFrame")
664-
expect_equal(count(df), 3)
665-
666-
rdd2 <- flatMap(rdd, function(x) c(x, x))
667-
df <- suppressWarnings(jsonRDD(sqlContext, rdd2))
668-
expect_is(df, "SparkDataFrame")
669-
expect_equal(count(df), 6)
670-
})
671-
672654
test_that("test tableNames and tables", {
673655
count <- count(listTables())
674656

@@ -2658,17 +2640,14 @@ test_that("read/write Parquet files", {
26582640
expect_is(df2, "SparkDataFrame")
26592641
expect_equal(count(df2), 3)
26602642

2661-
# Test write.parquet/saveAsParquetFile and read.parquet/parquetFile
2643+
# Test write.parquet/saveAsParquetFile and read.parquet
26622644
parquetPath2 <- tempfile(pattern = "parquetPath2", fileext = ".parquet")
26632645
write.parquet(df, parquetPath2)
26642646
parquetPath3 <- tempfile(pattern = "parquetPath3", fileext = ".parquet")
26652647
suppressWarnings(saveAsParquetFile(df, parquetPath3))
26662648
parquetDF <- read.parquet(c(parquetPath2, parquetPath3))
26672649
expect_is(parquetDF, "SparkDataFrame")
26682650
expect_equal(count(parquetDF), count(df) * 2)
2669-
parquetDF2 <- suppressWarnings(parquetFile(parquetPath2, parquetPath3))
2670-
expect_is(parquetDF2, "SparkDataFrame")
2671-
expect_equal(count(parquetDF2), count(df) * 2)
26722651

26732652
# Test if varargs works with variables
26742653
saveMode <- "overwrite"

docs/sparkr.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,12 @@ You can inspect the search path in R with [`search()`](https://stat.ethz.ch/R-ma
709709

710710
## Upgrading to SparkR 2.3.1 and above
711711

712-
- In SparkR 2.3.0 and earlier, the `start` parameter of `substr` method was wrongly subtracted by one and considered as 0-based. This can lead to inconsistent substring results and also does not match with the behaviour with `substr` in R. In version 2.3.1 and later, it has been fixed so the `start` parameter of `substr` method is now 1-base. As an example, `substr(lit('abcdef'), 2, 4))` would result to `abc` in SparkR 2.3.0, and the result would be `bcd` in SparkR 2.3.1.
712+
- In SparkR 2.3.0 and earlier, the `start` parameter of `substr` method was wrongly subtracted by one and considered as 0-based. This can lead to inconsistent substring results and also does not match with the behaviour with `substr` in R. In version 2.3.1 and later, it has been fixed so the `start` parameter of `substr` method is now 1-based. As an example, `substr(lit('abcdef'), 2, 4))` would result to `abc` in SparkR 2.3.0, and the result would be `bcd` in SparkR 2.3.1.
713713

714714
## Upgrading to SparkR 2.4.0
715715

716716
- Previously, we don't check the validity of the size of the last layer in `spark.mlp`. For example, if the training data only has two labels, a `layers` param like `c(1, 3)` doesn't cause an error previously, now it does.
717+
718+
## Upgrading to SparkR 3.0.0
719+
720+
- The deprecated methods `parquetFile`, `jsonRDD` and `jsonFile` in `SQLContext` have been removed. Use `read.parquet` and `read.json`.

0 commit comments

Comments
 (0)