Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/pkg/R/DataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -2614,7 +2614,7 @@ setMethod("join",
"left", "leftouter", "left_outer",
"right", "rightouter", "right_outer",
"semi", "left_semi", "leftsemi", "anti", "left_anti", "leftanti")) {
joinType <- gsub("_", "", joinType)
joinType <- gsub("_", "", joinType, fixed = TRUE)
sdf <- callJMethod(x@sdf, "join", y@sdf, joinExpr@jc, joinType)
} else {
stop(paste("joinType must be one of the following types:",
Expand Down
7 changes: 4 additions & 3 deletions R/pkg/R/SQLContext.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ sparkR.conf <- function(key, defaultValue) {
value <- if (missing(defaultValue)) {
tryCatch(callJMethod(conf, "get", key),
error = function(e) {
if (any(grep("java.util.NoSuchElementException", as.character(e)))) {
estr <- as.character(e)
if (any(grepl("java.util.NoSuchElementException", estr, fixed = TRUE))) {
stop(paste0("Config '", key, "' is not set"))
} else {
stop(paste0("Unknown error: ", as.character(e)))
stop(paste0("Unknown error: ", estr))
}
})
} else {
Expand Down Expand Up @@ -205,7 +206,7 @@ getSchema <- function(schema, firstRow = NULL, rdd = NULL) {
# SPAKR-SQL does not support '.' in column name, so replace it with '_'
# TODO(davies): remove this once SPARK-2775 is fixed
names <- lapply(names, function(n) {
nn <- gsub("[.]", "_", n)
nn <- gsub(".", "_", n, fixed = TRUE)
if (nn != n) {
warning(paste("Use", nn, "instead of", n, "as column name"))
}
Expand Down
10 changes: 5 additions & 5 deletions R/pkg/R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ checkJavaVersion <- function() {
javaHome <- Sys.getenv("JAVA_HOME")
javaReqs <- utils::packageDescription(utils::packageName(), fields = c("SystemRequirements"))
sparkJavaVersions <- strsplit(javaReqs, "[(,)]")[[1]]
minJavaVersion <- as.numeric(strsplit(sparkJavaVersions[[2]], ">= ")[[1]][[2]])
maxJavaVersion <- as.numeric(strsplit(sparkJavaVersions[[3]], "< ")[[1]][[2]])
minJavaVersion <- as.numeric(strsplit(sparkJavaVersions[[2]], ">= ", fixed = TRUE)[[1]][[2]])
maxJavaVersion <- as.numeric(strsplit(sparkJavaVersions[[3]], "< ", fixed = TRUE)[[1]][[2]])
if (javaHome != "") {
javaBin <- file.path(javaHome, "bin", javaBin)
}
Expand All @@ -89,13 +89,13 @@ checkJavaVersion <- function() {
})
javaVersionFilter <- Filter(
function(x) {
grepl(" version", x)
grepl(" version", x, fixed = TRUE)
}, javaVersionOut)

javaVersionStr <- strsplit(javaVersionFilter[[1]], "[\"]")[[1L]][2]
javaVersionStr <- strsplit(javaVersionFilter[[1]], '"', fixed = TRUE)[[1L]][2]
# javaVersionStr is of the form 1.8.0_92/9.0.x/11.0.x.
# We are using 8, 9, 10, 11 for sparkJavaVersion.
versions <- strsplit(javaVersionStr, "[.]")[[1L]]
versions <- strsplit(javaVersionStr, ".", fixed = TRUE)[[1L]]
if ("1" == versions[1]) {
javaVersionNum <- as.integer(versions[2])
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/pkg/R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ getPreferredMirror <- function(version, packageName) {
file.path("spark", version, packageName),
".tgz&as_json=1")
textLines <- readLines(jsonUrl, warn = FALSE)
rowNum <- grep("\"preferred\"", textLines)
rowNum <- grep('"preferred"', textLines, fixed = TRUE)
linePreferred <- textLines[rowNum]
matchInfo <- regexpr("\"[A-Za-z][A-Za-z0-9+-.]*://.+\"", linePreferred)
matchInfo <- regexpr('"[A-Za-z][A-Za-z0-9+-.]*://.+"', linePreferred)
if (matchInfo != -1) {
startPos <- matchInfo + 1
endPos <- matchInfo + attr(matchInfo, "match.length") - 2
Expand Down
2 changes: 1 addition & 1 deletion R/pkg/R/schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ checkType <- function(type) {
# strsplit does not return the final empty string, so check if
# the final char is ","
if (substr(fieldsString, nchar(fieldsString), nchar(fieldsString)) != ",") {
fields <- strsplit(fieldsString, ",")[[1]]
fields <- strsplit(fieldsString, ",", fixed = TRUE)[[1]]
for (field in fields) {
m <- regexec("^(.+):(.+)$", field)
matchedStrings <- regmatches(field, m)
Expand Down
4 changes: 2 additions & 2 deletions R/pkg/R/sparkR.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ sparkR.session <- function(
# Check if version number of SparkSession matches version number of SparkR package
jvmVersion <- callJMethod(sparkSession, "version")
# Remove -SNAPSHOT from jvm versions
jvmVersionStrip <- gsub("-SNAPSHOT", "", jvmVersion)
jvmVersionStrip <- gsub("-SNAPSHOT", "", jvmVersion, fixed = TRUE)
rPackageVersion <- paste0(packageVersion("SparkR"))

if (jvmVersionStrip != rPackageVersion) {
Expand Down Expand Up @@ -606,7 +606,7 @@ getClientModeSparkSubmitOpts <- function(submitOps, sparkEnvirMap) {
# process only if --option is not already specified
if (!is.null(opsValue) &&
nchar(opsValue) > 1 &&
!grepl(sparkConfToSubmitOps[[conf]], submitOps)) {
!grepl(sparkConfToSubmitOps[[conf]], submitOps, fixed = TRUE)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could actually be a bug fix too for very, very unlikely corner cases such as spark.driver.memory <> sparkAdriverXmemory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes exactly. there were a few other like this in utils.R e.g.

grep("org.apache.spark.sql.streaming.StreamingQueryException: "

# put "" around value in case it has spaces
paste0(sparkConfToSubmitOps[[conf]], " \"", opsValue, "\" ")
} else {
Expand Down
16 changes: 10 additions & 6 deletions R/pkg/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -818,30 +818,32 @@ captureJVMException <- function(e, method) {
}

# StreamingQueryException could wrap an IllegalArgumentException, so look for that first
if (any(grep("org.apache.spark.sql.streaming.StreamingQueryException: ", stacktrace))) {
if (any(grep("org.apache.spark.sql.streaming.StreamingQueryException: ",
stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "org.apache.spark.sql.streaming.StreamingQueryException: ",
fixed = TRUE)[[1]]
# Extract "Error in ..." message.
rmsg <- msg[1]
# Extract the first message of JVM exception.
first <- strsplit(msg[2], "\r?\n\tat")[[1]][1]
stop(paste0(rmsg, "streaming query error - ", first), call. = FALSE)
} else if (any(grep("java.lang.IllegalArgumentException: ", stacktrace))) {
} else if (any(grep("java.lang.IllegalArgumentException: ", stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "java.lang.IllegalArgumentException: ", fixed = TRUE)[[1]]
# Extract "Error in ..." message.
rmsg <- msg[1]
# Extract the first message of JVM exception.
first <- strsplit(msg[2], "\r?\n\tat")[[1]][1]
stop(paste0(rmsg, "illegal argument - ", first), call. = FALSE)
} else if (any(grep("org.apache.spark.sql.AnalysisException: ", stacktrace))) {
} else if (any(grep("org.apache.spark.sql.AnalysisException: ", stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "org.apache.spark.sql.AnalysisException: ", fixed = TRUE)[[1]]
# Extract "Error in ..." message.
rmsg <- msg[1]
# Extract the first message of JVM exception.
first <- strsplit(msg[2], "\r?\n\tat")[[1]][1]
stop(paste0(rmsg, "analysis error - ", first), call. = FALSE)
} else
if (any(grep("org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: ", stacktrace))) {
if (any(grep("org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: ",
stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: ",
fixed = TRUE)[[1]]
# Extract "Error in ..." message.
Expand All @@ -850,15 +852,17 @@ captureJVMException <- function(e, method) {
first <- strsplit(msg[2], "\r?\n\tat")[[1]][1]
stop(paste0(rmsg, "no such database - ", first), call. = FALSE)
} else
if (any(grep("org.apache.spark.sql.catalyst.analysis.NoSuchTableException: ", stacktrace))) {
if (any(grep("org.apache.spark.sql.catalyst.analysis.NoSuchTableException: ",
stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "org.apache.spark.sql.catalyst.analysis.NoSuchTableException: ",
fixed = TRUE)[[1]]
# Extract "Error in ..." message.
rmsg <- msg[1]
# Extract the first message of JVM exception.
first <- strsplit(msg[2], "\r?\n\tat")[[1]][1]
stop(paste0(rmsg, "no such table - ", first), call. = FALSE)
} else if (any(grep("org.apache.spark.sql.catalyst.parser.ParseException: ", stacktrace))) {
} else if (any(grep("org.apache.spark.sql.catalyst.parser.ParseException: ",
stacktrace, fixed = TRUE))) {
msg <- strsplit(stacktrace, "org.apache.spark.sql.catalyst.parser.ParseException: ",
fixed = TRUE)[[1]]
# Extract "Error in ..." message.
Expand Down