Skip to content

Commit 7d19977

Browse files
committed
Merge remote-tracking branch 'upstream/master' into arrow-toPandas-oo-batches-SPARK-25274
2 parents 0d77b00 + f6cc354 commit 7d19977

1,076 files changed

Lines changed: 32995 additions & 28583 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.travis.yml‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎R/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export R_HOME=/home/username/R
1717

1818
#### Build Spark
1919

20-
Build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#building-with-buildmvn) and include the `-Psparkr` profile to build the R package. For example to use the default Hadoop versions you can run
20+
Build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#buildmvn) and include the `-Psparkr` profile to build the R package. For example to use the default Hadoop versions you can run
2121

2222
```bash
2323
build/mvn -DskipTests -Psparkr package

‎R/WINDOWS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ directory in Maven in `PATH`.
1414

1515
4. Set `MAVEN_OPTS` as described in [Building Spark](http://spark.apache.org/docs/latest/building-spark.html).
1616

17-
5. Open a command shell (`cmd`) in the Spark directory and build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#building-with-buildmvn) and include the `-Psparkr` profile to build the R package. For example to use the default Hadoop versions you can run
17+
5. Open a command shell (`cmd`) in the Spark directory and build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#buildmvn) and include the `-Psparkr` profile to build the R package. For example to use the default Hadoop versions you can run
1818

1919
```bash
2020
mvn.cmd -DskipTests -Psparkr package

‎R/pkg/DESCRIPTION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: SparkR
22
Type: Package
3-
Version: 2.4.0
3+
Version: 3.0.0
44
Title: R Frontend for Apache Spark
55
Description: Provides an R Frontend for Apache Spark.
66
Authors@R: c(person("Shivaram", "Venkataraman", role = c("aut", "cre"),

‎R/pkg/NAMESPACE‎

Lines changed: 8 additions & 13 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",
@@ -70,7 +66,8 @@ exportMethods("glm",
7066
"spark.svmLinear",
7167
"spark.fpGrowth",
7268
"spark.freqItemsets",
73-
"spark.associationRules")
69+
"spark.associationRules",
70+
"spark.findFrequentSequentialPatterns")
7471

7572
# Job group lifecycle management methods
7673
export("setJobGroup",
@@ -150,15 +147,13 @@ exportMethods("arrange",
150147
"printSchema",
151148
"randomSplit",
152149
"rbind",
153-
"registerTempTable",
154150
"rename",
155151
"repartition",
156152
"repartitionByRange",
157153
"rollup",
158154
"sample",
159155
"sample_frac",
160156
"sampleBy",
161-
"saveAsParquetFile",
162157
"saveAsTable",
163158
"saveDF",
164159
"schema",
@@ -174,7 +169,6 @@ exportMethods("arrange",
174169
"toJSON",
175170
"transform",
176171
"union",
177-
"unionAll",
178172
"unionByName",
179173
"unique",
180174
"unpersist",
@@ -204,6 +198,8 @@ exportMethods("%<=>%",
204198
"approxQuantile",
205199
"array_contains",
206200
"array_distinct",
201+
"array_except",
202+
"array_intersect",
207203
"array_join",
208204
"array_max",
209205
"array_min",
@@ -212,6 +208,7 @@ exportMethods("%<=>%",
212208
"array_repeat",
213209
"array_sort",
214210
"arrays_overlap",
211+
"array_union",
215212
"arrays_zip",
216213
"asc",
217214
"ascii",
@@ -271,6 +268,7 @@ exportMethods("%<=>%",
271268
"floor",
272269
"format_number",
273270
"format_string",
271+
"from_csv",
274272
"from_json",
275273
"from_unixtime",
276274
"from_utc_timestamp",
@@ -355,6 +353,7 @@ exportMethods("%<=>%",
355353
"shiftLeft",
356354
"shiftRight",
357355
"shiftRightUnsigned",
356+
"shuffle",
358357
"sd",
359358
"sign",
360359
"signum",
@@ -409,18 +408,14 @@ export("as.DataFrame",
409408
"cacheTable",
410409
"clearCache",
411410
"createDataFrame",
412-
"createExternalTable",
413411
"createTable",
414412
"currentDatabase",
415-
"dropTempTable",
416413
"dropTempView",
417-
"jsonFile",
418414
"listColumns",
419415
"listDatabases",
420416
"listFunctions",
421417
"listTables",
422418
"loadDF",
423-
"parquetFile",
424419
"read.df",
425420
"read.jdbc",
426421
"read.json",

‎R/pkg/R/DataFrame.R‎

Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ setMethod("showDF",
226226

227227
#' show
228228
#'
229-
#' Print class and type information of a Spark object.
229+
#' 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
231+
#' and type information of the Spark object.
230232
#'
231233
#' @param object a Spark object. Can be a SparkDataFrame, Column, GroupedData, WindowSpec.
232234
#'
@@ -244,11 +246,33 @@ setMethod("showDF",
244246
#' @note show(SparkDataFrame) since 1.4.0
245247
setMethod("show", "SparkDataFrame",
246248
function(object) {
247-
cols <- lapply(dtypes(object), function(l) {
248-
paste(l, collapse = ":")
249-
})
250-
s <- paste(cols, collapse = ", ")
251-
cat(paste(class(object), "[", s, "]\n", sep = ""))
249+
allConf <- sparkR.conf()
250+
prop <- allConf[["spark.sql.repl.eagerEval.enabled"]]
251+
if (!is.null(prop) && identical(prop, "true")) {
252+
argsList <- list()
253+
argsList$x <- object
254+
prop <- allConf[["spark.sql.repl.eagerEval.maxNumRows"]]
255+
if (!is.null(prop)) {
256+
numRows <- as.integer(prop)
257+
if (numRows > 0) {
258+
argsList$numRows <- numRows
259+
}
260+
}
261+
prop <- allConf[["spark.sql.repl.eagerEval.truncate"]]
262+
if (!is.null(prop)) {
263+
truncate <- as.integer(prop)
264+
if (truncate > 0) {
265+
argsList$truncate <- truncate
266+
}
267+
}
268+
do.call(showDF, argsList)
269+
} else {
270+
cols <- lapply(dtypes(object), function(l) {
271+
paste(l, collapse = ":")
272+
})
273+
s <- paste(cols, collapse = ", ")
274+
cat(paste(class(object), "[", s, "]\n", sep = ""))
275+
}
252276
})
253277

254278
#' DataTypes
@@ -497,33 +521,6 @@ setMethod("createOrReplaceTempView",
497521
invisible(callJMethod(x@sdf, "createOrReplaceTempView", viewName))
498522
})
499523

500-
#' (Deprecated) Register Temporary Table
501-
#'
502-
#' Registers a SparkDataFrame as a Temporary Table in the SparkSession
503-
#' @param x A SparkDataFrame
504-
#' @param tableName A character vector containing the name of the table
505-
#'
506-
#' @family SparkDataFrame functions
507-
#' @seealso \link{createOrReplaceTempView}
508-
#' @rdname registerTempTable-deprecated
509-
#' @name registerTempTable
510-
#' @aliases registerTempTable,SparkDataFrame,character-method
511-
#' @examples
512-
#'\dontrun{
513-
#' sparkR.session()
514-
#' path <- "path/to/file.json"
515-
#' df <- read.json(path)
516-
#' registerTempTable(df, "json_df")
517-
#' new_df <- sql("SELECT * FROM json_df")
518-
#'}
519-
#' @note registerTempTable since 1.4.0
520-
setMethod("registerTempTable",
521-
signature(x = "SparkDataFrame", tableName = "character"),
522-
function(x, tableName) {
523-
.Deprecated("createOrReplaceTempView")
524-
invisible(callJMethod(x@sdf, "createOrReplaceTempView", tableName))
525-
})
526-
527524
#' insertInto
528525
#'
529526
#' Insert the contents of a SparkDataFrame into a table registered in the current SparkSession.
@@ -933,7 +930,6 @@ setMethod("write.orc",
933930
#' path <- "path/to/file.json"
934931
#' df <- read.json(path)
935932
#' write.parquet(df, "/tmp/sparkr-tmp1/")
936-
#' saveAsParquetFile(df, "/tmp/sparkr-tmp2/")
937933
#'}
938934
#' @note write.parquet since 1.6.0
939935
setMethod("write.parquet",
@@ -944,17 +940,6 @@ setMethod("write.parquet",
944940
invisible(handledCallJMethod(write, "parquet", path))
945941
})
946942

947-
#' @rdname write.parquet
948-
#' @name saveAsParquetFile
949-
#' @aliases saveAsParquetFile,SparkDataFrame,character-method
950-
#' @note saveAsParquetFile since 1.4.0
951-
setMethod("saveAsParquetFile",
952-
signature(x = "SparkDataFrame", path = "character"),
953-
function(x, path) {
954-
.Deprecated("write.parquet")
955-
write.parquet(x, path)
956-
})
957-
958943
#' Save the content of SparkDataFrame in a text file at the specified path.
959944
#'
960945
#' Save the content of the SparkDataFrame in a text file at the specified path.
@@ -2739,18 +2724,6 @@ setMethod("union",
27392724
dataFrame(unioned)
27402725
})
27412726

2742-
#' unionAll is deprecated - use union instead
2743-
#' @rdname union
2744-
#' @name unionAll
2745-
#' @aliases unionAll,SparkDataFrame,SparkDataFrame-method
2746-
#' @note unionAll since 1.4.0
2747-
setMethod("unionAll",
2748-
signature(x = "SparkDataFrame", y = "SparkDataFrame"),
2749-
function(x, y) {
2750-
.Deprecated("union")
2751-
union(x, y)
2752-
})
2753-
27542727
#' Return a new SparkDataFrame containing the union of rows, matched by column names
27552728
#'
27562729
#' Return a new SparkDataFrame containing the union of rows in this SparkDataFrame
@@ -2955,6 +2928,9 @@ setMethod("exceptAll",
29552928
#' @param source a name for external data source.
29562929
#' @param mode one of 'append', 'overwrite', 'error', 'errorifexists', 'ignore'
29572930
#' save mode (it is 'error' by default)
2931+
#' @param partitionBy a name or a list of names of columns to partition the output by on the file
2932+
#' system. If specified, the output is laid out on the file system similar
2933+
#' to Hive's partitioning scheme.
29582934
#' @param ... additional argument(s) passed to the method.
29592935
#'
29602936
#' @family SparkDataFrame functions
@@ -2966,13 +2942,13 @@ setMethod("exceptAll",
29662942
#' sparkR.session()
29672943
#' path <- "path/to/file.json"
29682944
#' df <- read.json(path)
2969-
#' write.df(df, "myfile", "parquet", "overwrite")
2945+
#' write.df(df, "myfile", "parquet", "overwrite", partitionBy = c("col1", "col2"))
29702946
#' saveDF(df, parquetPath2, "parquet", mode = "append", mergeSchema = TRUE)
29712947
#' }
29722948
#' @note write.df since 1.4.0
29732949
setMethod("write.df",
29742950
signature(df = "SparkDataFrame"),
2975-
function(df, path = NULL, source = NULL, mode = "error", ...) {
2951+
function(df, path = NULL, source = NULL, mode = "error", partitionBy = NULL, ...) {
29762952
if (!is.null(path) && !is.character(path)) {
29772953
stop("path should be character, NULL or omitted.")
29782954
}
@@ -2986,8 +2962,18 @@ setMethod("write.df",
29862962
if (is.null(source)) {
29872963
source <- getDefaultSqlSource()
29882964
}
2965+
cols <- NULL
2966+
if (!is.null(partitionBy)) {
2967+
if (!all(sapply(partitionBy, function(c) is.character(c)))) {
2968+
stop("All partitionBy column names should be characters.")
2969+
}
2970+
cols <- as.list(partitionBy)
2971+
}
29892972
write <- callJMethod(df@sdf, "write")
29902973
write <- callJMethod(write, "format", source)
2974+
if (!is.null(cols)) {
2975+
write <- callJMethod(write, "partitionBy", cols)
2976+
}
29912977
write <- setWriteOptions(write, path = path, mode = mode, ...)
29922978
write <- handledCallJMethod(write, "save")
29932979
})
@@ -3986,7 +3972,17 @@ setMethod("hint",
39863972
signature(x = "SparkDataFrame", name = "character"),
39873973
function(x, name, ...) {
39883974
parameters <- list(...)
3989-
stopifnot(all(sapply(parameters, is.character)))
3975+
if (!all(sapply(parameters, function(y) {
3976+
if (is.character(y) || is.numeric(y)) {
3977+
TRUE
3978+
} else if (is.list(y)) {
3979+
all(sapply(y, function(z) { is.character(z) || is.numeric(z) }))
3980+
} else {
3981+
FALSE
3982+
}
3983+
}))) {
3984+
stop("sql hint should be character, numeric, or list with character or numeric.")
3985+
}
39903986
jdf <- callJMethod(x@sdf, "hint", name, parameters)
39913987
dataFrame(jdf)
39923988
})

0 commit comments

Comments
 (0)