Skip to content

Commit 8b71061

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-codege-compilation-error
2 parents 448abfa + 9db06c4 commit 8b71061

File tree

321 files changed

+8825
-4042
lines changed

Some content is hidden

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

321 files changed

+8825
-4042
lines changed

R/pkg/R/DataFrame.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ setMethod("write.json",
788788
function(x, path, mode = "error", ...) {
789789
write <- callJMethod(x@sdf, "write")
790790
write <- setWriteOptions(write, mode = mode, ...)
791-
invisible(callJMethod(write, "json", path))
791+
invisible(handledCallJMethod(write, "json", path))
792792
})
793793

794794
#' Save the contents of SparkDataFrame as an ORC file, preserving the schema.
@@ -819,7 +819,7 @@ setMethod("write.orc",
819819
function(x, path, mode = "error", ...) {
820820
write <- callJMethod(x@sdf, "write")
821821
write <- setWriteOptions(write, mode = mode, ...)
822-
invisible(callJMethod(write, "orc", path))
822+
invisible(handledCallJMethod(write, "orc", path))
823823
})
824824

825825
#' Save the contents of SparkDataFrame as a Parquet file, preserving the schema.
@@ -851,7 +851,7 @@ setMethod("write.parquet",
851851
function(x, path, mode = "error", ...) {
852852
write <- callJMethod(x@sdf, "write")
853853
write <- setWriteOptions(write, mode = mode, ...)
854-
invisible(callJMethod(write, "parquet", path))
854+
invisible(handledCallJMethod(write, "parquet", path))
855855
})
856856

857857
#' @rdname write.parquet
@@ -895,7 +895,7 @@ setMethod("write.text",
895895
function(x, path, mode = "error", ...) {
896896
write <- callJMethod(x@sdf, "write")
897897
write <- setWriteOptions(write, mode = mode, ...)
898-
invisible(callJMethod(write, "text", path))
898+
invisible(handledCallJMethod(write, "text", path))
899899
})
900900

901901
#' Distinct
@@ -3342,7 +3342,7 @@ setMethod("write.jdbc",
33423342
jprops <- varargsToJProperties(...)
33433343
write <- callJMethod(x@sdf, "write")
33443344
write <- callJMethod(write, "mode", jmode)
3345-
invisible(callJMethod(write, "jdbc", url, tableName, jprops))
3345+
invisible(handledCallJMethod(write, "jdbc", url, tableName, jprops))
33463346
})
33473347

33483348
#' randomSplit

R/pkg/R/SQLContext.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ read.json.default <- function(path, ...) {
350350
paths <- as.list(suppressWarnings(normalizePath(path)))
351351
read <- callJMethod(sparkSession, "read")
352352
read <- callJMethod(read, "options", options)
353-
sdf <- callJMethod(read, "json", paths)
353+
sdf <- handledCallJMethod(read, "json", paths)
354354
dataFrame(sdf)
355355
}
356356

@@ -422,7 +422,7 @@ read.orc <- function(path, ...) {
422422
path <- suppressWarnings(normalizePath(path))
423423
read <- callJMethod(sparkSession, "read")
424424
read <- callJMethod(read, "options", options)
425-
sdf <- callJMethod(read, "orc", path)
425+
sdf <- handledCallJMethod(read, "orc", path)
426426
dataFrame(sdf)
427427
}
428428

@@ -444,7 +444,7 @@ read.parquet.default <- function(path, ...) {
444444
paths <- as.list(suppressWarnings(normalizePath(path)))
445445
read <- callJMethod(sparkSession, "read")
446446
read <- callJMethod(read, "options", options)
447-
sdf <- callJMethod(read, "parquet", paths)
447+
sdf <- handledCallJMethod(read, "parquet", paths)
448448
dataFrame(sdf)
449449
}
450450

@@ -496,7 +496,7 @@ read.text.default <- function(path, ...) {
496496
paths <- as.list(suppressWarnings(normalizePath(path)))
497497
read <- callJMethod(sparkSession, "read")
498498
read <- callJMethod(read, "options", options)
499-
sdf <- callJMethod(read, "text", paths)
499+
sdf <- handledCallJMethod(read, "text", paths)
500500
dataFrame(sdf)
501501
}
502502

@@ -914,12 +914,13 @@ read.jdbc <- function(url, tableName,
914914
} else {
915915
numPartitions <- numToInt(numPartitions)
916916
}
917-
sdf <- callJMethod(read, "jdbc", url, tableName, as.character(partitionColumn),
918-
numToInt(lowerBound), numToInt(upperBound), numPartitions, jprops)
917+
sdf <- handledCallJMethod(read, "jdbc", url, tableName, as.character(partitionColumn),
918+
numToInt(lowerBound), numToInt(upperBound), numPartitions, jprops)
919919
} else if (length(predicates) > 0) {
920-
sdf <- callJMethod(read, "jdbc", url, tableName, as.list(as.character(predicates)), jprops)
920+
sdf <- handledCallJMethod(read, "jdbc", url, tableName, as.list(as.character(predicates)),
921+
jprops)
921922
} else {
922-
sdf <- callJMethod(read, "jdbc", url, tableName, jprops)
923+
sdf <- handledCallJMethod(read, "jdbc", url, tableName, jprops)
923924
}
924925
dataFrame(sdf)
925926
}

R/pkg/R/functions.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ setMethod("soundex",
14851485

14861486
#' Return the partition ID as a column
14871487
#'
1488-
#' Return the partition ID of the Spark task as a SparkDataFrame column.
1488+
#' Return the partition ID as a SparkDataFrame column.
14891489
#' Note that this is nondeterministic because it depends on data partitioning and
14901490
#' task scheduling.
14911491
#'
@@ -2317,7 +2317,8 @@ setMethod("date_format", signature(y = "Column", x = "character"),
23172317

23182318
#' from_utc_timestamp
23192319
#'
2320-
#' Assumes given timestamp is UTC and converts to given timezone.
2320+
#' Given a timestamp, which corresponds to a certain time of day in UTC, returns another timestamp
2321+
#' that corresponds to the same time of day in the given timezone.
23212322
#'
23222323
#' @param y Column to compute on.
23232324
#' @param x time zone to use.
@@ -2340,7 +2341,7 @@ setMethod("from_utc_timestamp", signature(y = "Column", x = "character"),
23402341
#' Locate the position of the first occurrence of substr column in the given string.
23412342
#' Returns null if either of the arguments are null.
23422343
#'
2343-
#' NOTE: The position is not zero based, but 1 based index, returns 0 if substr
2344+
#' NOTE: The position is not zero based, but 1 based index. Returns 0 if substr
23442345
#' could not be found in str.
23452346
#'
23462347
#' @param y column to check
@@ -2391,7 +2392,8 @@ setMethod("next_day", signature(y = "Column", x = "character"),
23912392

23922393
#' to_utc_timestamp
23932394
#'
2394-
#' Assumes given timestamp is in given timezone and converts to UTC.
2395+
#' Given a timestamp, which corresponds to a certain time of day in the given timezone, returns
2396+
#' another timestamp that corresponds to the same time of day in UTC.
23952397
#'
23962398
#' @param y Column to compute on
23972399
#' @param x timezone to use
@@ -2539,7 +2541,7 @@ setMethod("shiftLeft", signature(y = "Column", x = "numeric"),
25392541

25402542
#' shiftRight
25412543
#'
2542-
#' Shift the given value numBits right. If the given value is a long value, it will return
2544+
#' (Signed) shift the given value numBits right. If the given value is a long value, it will return
25432545
#' a long value else it will return an integer value.
25442546
#'
25452547
#' @param y column to compute on.
@@ -2777,7 +2779,7 @@ setMethod("window", signature(x = "Column"),
27772779
#' locate
27782780
#'
27792781
#' Locate the position of the first occurrence of substr.
2780-
#' NOTE: The position is not zero based, but 1 based index, returns 0 if substr
2782+
#' NOTE: The position is not zero based, but 1 based index. Returns 0 if substr
27812783
#' could not be found in str.
27822784
#'
27832785
#' @param substr a character string to be matched.
@@ -2823,7 +2825,8 @@ setMethod("lpad", signature(x = "Column", len = "numeric", pad = "character"),
28232825

28242826
#' rand
28252827
#'
2826-
#' Generate a random column with i.i.d. samples from U[0.0, 1.0].
2828+
#' Generate a random column with independent and identically distributed (i.i.d.) samples
2829+
#' from U[0.0, 1.0].
28272830
#'
28282831
#' @param seed a random seed. Can be missing.
28292832
#' @family normal_funcs
@@ -2852,7 +2855,8 @@ setMethod("rand", signature(seed = "numeric"),
28522855

28532856
#' randn
28542857
#'
2855-
#' Generate a column with i.i.d. samples from the standard normal distribution.
2858+
#' Generate a column with independent and identically distributed (i.i.d.) samples from
2859+
#' the standard normal distribution.
28562860
#'
28572861
#' @param seed a random seed. Can be missing.
28582862
#' @family normal_funcs
@@ -3442,8 +3446,8 @@ setMethod("size",
34423446

34433447
#' sort_array
34443448
#'
3445-
#' Sorts the input array for the given column in ascending order,
3446-
#' according to the natural ordering of the array elements.
3449+
#' Sorts the input array in ascending or descending order according
3450+
#' to the natural ordering of the array elements.
34473451
#'
34483452
#' @param x A Column to sort
34493453
#' @param asc A logical flag indicating the sorting order.

R/pkg/R/utils.R

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,41 @@ varargsToEnv <- function(...) {
338338
# into string.
339339
varargsToStrEnv <- function(...) {
340340
pairs <- list(...)
341+
nameList <- names(pairs)
341342
env <- new.env()
342-
for (name in names(pairs)) {
343-
value <- pairs[[name]]
344-
if (!(is.logical(value) || is.numeric(value) || is.character(value) || is.null(value))) {
345-
stop(paste0("Unsupported type for ", name, " : ", class(value),
346-
". Supported types are logical, numeric, character and NULL."))
347-
}
348-
if (is.logical(value)) {
349-
env[[name]] <- tolower(as.character(value))
350-
} else if (is.null(value)) {
351-
env[[name]] <- value
352-
} else {
353-
env[[name]] <- as.character(value)
343+
ignoredNames <- list()
344+
345+
if (is.null(nameList)) {
346+
# When all arguments are not named, names(..) returns NULL.
347+
ignoredNames <- pairs
348+
} else {
349+
for (i in seq_along(pairs)) {
350+
name <- nameList[i]
351+
value <- pairs[i]
352+
if (identical(name, "")) {
353+
# When some of arguments are not named, name is "".
354+
ignoredNames <- append(ignoredNames, value)
355+
} else {
356+
value <- pairs[[name]]
357+
if (!(is.logical(value) || is.numeric(value) || is.character(value) || is.null(value))) {
358+
stop(paste0("Unsupported type for ", name, " : ", class(value),
359+
". Supported types are logical, numeric, character and NULL."), call. = FALSE)
360+
}
361+
if (is.logical(value)) {
362+
env[[name]] <- tolower(as.character(value))
363+
} else if (is.null(value)) {
364+
env[[name]] <- value
365+
} else {
366+
env[[name]] <- as.character(value)
367+
}
368+
}
354369
}
355370
}
371+
372+
if (length(ignoredNames) != 0) {
373+
warning(paste0("Unnamed arguments ignored: ", paste(ignoredNames, collapse = ", "), "."),
374+
call. = FALSE)
375+
}
356376
env
357377
}
358378

R/pkg/inst/tests/testthat/test_mllib.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test_that("spark.glm summary", {
133133
w <- c(1, 2, 3, 4)
134134
b <- c(1, 0, 1, 0)
135135
data <- as.data.frame(cbind(a1, a2, w, b))
136-
df <- suppressWarnings(createDataFrame(data))
136+
df <- createDataFrame(data)
137137

138138
stats <- summary(spark.glm(df, b ~ a1 + a2, family = "binomial", weightCol = "w"))
139139
rStats <- summary(glm(b ~ a1 + a2, family = "binomial", data = data, weights = w))
@@ -575,7 +575,7 @@ test_that("spark.isotonicRegression", {
575575
feature <- c(0.0, 1.0, 2.0, 3.0, 4.0)
576576
weight <- c(1.0, 1.0, 1.0, 1.0, 1.0)
577577
data <- as.data.frame(cbind(label, feature, weight))
578-
df <- suppressWarnings(createDataFrame(data))
578+
df <- createDataFrame(data)
579579

580580
model <- spark.isoreg(df, label ~ feature, isotonic = FALSE,
581581
weightCol = "weight")

R/pkg/inst/tests/testthat/test_sparkSQL.R

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,16 +1222,16 @@ test_that("column functions", {
12221222
# Test struct()
12231223
df <- createDataFrame(list(list(1L, 2L, 3L), list(4L, 5L, 6L)),
12241224
schema = c("a", "b", "c"))
1225-
result <- collect(select(df, struct("a", "c")))
1225+
result <- collect(select(df, alias(struct("a", "c"), "d")))
12261226
expected <- data.frame(row.names = 1:2)
1227-
expected$"struct(a, c)" <- list(listToStruct(list(a = 1L, c = 3L)),
1228-
listToStruct(list(a = 4L, c = 6L)))
1227+
expected$"d" <- list(listToStruct(list(a = 1L, c = 3L)),
1228+
listToStruct(list(a = 4L, c = 6L)))
12291229
expect_equal(result, expected)
12301230

1231-
result <- collect(select(df, struct(df$a, df$b)))
1231+
result <- collect(select(df, alias(struct(df$a, df$b), "d")))
12321232
expected <- data.frame(row.names = 1:2)
1233-
expected$"struct(a, b)" <- list(listToStruct(list(a = 1L, b = 2L)),
1234-
listToStruct(list(a = 4L, b = 5L)))
1233+
expected$"d" <- list(listToStruct(list(a = 1L, b = 2L)),
1234+
listToStruct(list(a = 4L, b = 5L)))
12351235
expect_equal(result, expected)
12361236

12371237
# Test encode(), decode()
@@ -2659,7 +2659,15 @@ test_that("Call DataFrameWriter.save() API in Java without path and check argume
26592659
# It makes sure that we can omit path argument in write.df API and then it calls
26602660
# DataFrameWriter.save() without path.
26612661
expect_error(write.df(df, source = "csv"),
2662-
"Error in save : illegal argument - 'path' is not specified")
2662+
"Error in save : illegal argument - Expected exactly one path to be specified")
2663+
expect_error(write.json(df, jsonPath),
2664+
"Error in json : analysis error - path file:.*already exists")
2665+
expect_error(write.text(df, jsonPath),
2666+
"Error in text : analysis error - path file:.*already exists")
2667+
expect_error(write.orc(df, jsonPath),
2668+
"Error in orc : analysis error - path file:.*already exists")
2669+
expect_error(write.parquet(df, jsonPath),
2670+
"Error in parquet : analysis error - path file:.*already exists")
26632671

26642672
# Arguments checking in R side.
26652673
expect_error(write.df(df, "data.tmp", source = c(1, 2)),
@@ -2679,13 +2687,21 @@ test_that("Call DataFrameWriter.load() API in Java without path and check argume
26792687
paste("Error in loadDF : analysis error - Unable to infer schema for JSON at .",
26802688
"It must be specified manually"))
26812689
expect_error(read.df("arbitrary_path"), "Error in loadDF : analysis error - Path does not exist")
2690+
expect_error(read.json("arbitrary_path"), "Error in json : analysis error - Path does not exist")
2691+
expect_error(read.text("arbitrary_path"), "Error in text : analysis error - Path does not exist")
2692+
expect_error(read.orc("arbitrary_path"), "Error in orc : analysis error - Path does not exist")
2693+
expect_error(read.parquet("arbitrary_path"),
2694+
"Error in parquet : analysis error - Path does not exist")
26822695

26832696
# Arguments checking in R side.
26842697
expect_error(read.df(path = c(3)),
26852698
"path should be charactor, NULL or omitted.")
26862699
expect_error(read.df(jsonPath, source = c(1, 2)),
26872700
paste("source should be character, NULL or omitted. It is the datasource specified",
26882701
"in 'spark.sql.sources.default' configuration by default."))
2702+
2703+
expect_warning(read.json(jsonPath, a = 1, 2, 3, "a"),
2704+
"Unnamed arguments ignored: 2, 3, a.")
26892705
})
26902706

26912707
unlink(parquetPath)

R/pkg/inst/tests/testthat/test_utils.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ test_that("varargsToStrEnv", {
224224
expect_error(varargsToStrEnv(a = list(1, "a")),
225225
paste0("Unsupported type for a : list. Supported types are logical, ",
226226
"numeric, character and NULL."))
227+
expect_warning(varargsToStrEnv(a = 1, 2, 3, 4), "Unnamed arguments ignored: 2, 3, 4.")
228+
expect_warning(varargsToStrEnv(1, 2, 3, 4), "Unnamed arguments ignored: 1, 2, 3, 4.")
227229
})
228230

229231
sparkR.session.stop()

core/src/main/resources/org/apache/spark/ui/static/table.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function toggleThreadStackTrace(threadId, forceAdd) {
3636
if (stackTrace.length == 0) {
3737
var stackTraceText = $('#' + threadId + "_td_stacktrace").html()
3838
var threadCell = $("#thread_" + threadId + "_tr")
39-
threadCell.after("<tr id=\"" + threadId +"_stacktrace\" class=\"accordion-body\"><td colspan=\"3\"><pre>" +
39+
threadCell.after("<tr id=\"" + threadId +"_stacktrace\" class=\"accordion-body\"><td colspan=\"4\"><pre>" +
4040
stackTraceText + "</pre></td></tr>")
4141
} else {
4242
if (!forceAdd) {
@@ -73,6 +73,7 @@ function onMouseOverAndOut(threadId) {
7373
$("#" + threadId + "_td_id").toggleClass("threaddump-td-mouseover");
7474
$("#" + threadId + "_td_name").toggleClass("threaddump-td-mouseover");
7575
$("#" + threadId + "_td_state").toggleClass("threaddump-td-mouseover");
76+
$("#" + threadId + "_td_locking").toggleClass("threaddump-td-mouseover");
7677
}
7778

7879
function onSearchStringChange() {

0 commit comments

Comments
 (0)