From 932da74f4ce809eb428c2b4c502f19c8baf92cdc Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 3 Jun 2022 17:34:53 +0900 Subject: [PATCH 1/5] Update R version to 4.2.0 in AppVeyor --- dev/appveyor-install-dependencies.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/appveyor-install-dependencies.ps1 b/dev/appveyor-install-dependencies.ps1 index d469c98fdb3a2..7610c7b43b990 100644 --- a/dev/appveyor-install-dependencies.ps1 +++ b/dev/appveyor-install-dependencies.ps1 @@ -129,8 +129,8 @@ $env:PATH = "$env:HADOOP_HOME\bin;" + $env:PATH Pop-Location # ========================== R -$rVer = "4.0.2" -$rToolsVer = "4.0.2" +$rVer = "4.2.0" +$rToolsVer = "4.2.0" InstallR InstallRtools From 239a275fbb912adb1a442b67d1712fb8ab537292 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 3 Jun 2022 19:05:01 +0900 Subject: [PATCH 2/5] Keep the Rtools version as 4.0 for now --- dev/appveyor-install-dependencies.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/appveyor-install-dependencies.ps1 b/dev/appveyor-install-dependencies.ps1 index 7610c7b43b990..19b49b90b3859 100644 --- a/dev/appveyor-install-dependencies.ps1 +++ b/dev/appveyor-install-dependencies.ps1 @@ -130,7 +130,7 @@ Pop-Location # ========================== R $rVer = "4.2.0" -$rToolsVer = "4.2.0" +$rToolsVer = "4.0.2" InstallR InstallRtools From e398d4d53633b480d0e6562f374bf0e696593b23 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 3 Jun 2022 20:05:02 +0900 Subject: [PATCH 3/5] Use is.matrix to check if the input is a matrix --- R/pkg/R/mllib_classification.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/pkg/R/mllib_classification.R b/R/pkg/R/mllib_classification.R index 093467ecf7d28..10fdac77244e9 100644 --- a/R/pkg/R/mllib_classification.R +++ b/R/pkg/R/mllib_classification.R @@ -322,7 +322,7 @@ setMethod("spark.logit", signature(data = "SparkDataFrame", formula = "formula") } if (!is.null(lowerBoundsOnCoefficients)) { - if (class(lowerBoundsOnCoefficients) != "matrix") { + if (is.matrix(lowerBoundsOnCoefficients)) { stop("lowerBoundsOnCoefficients must be a matrix.") } row <- nrow(lowerBoundsOnCoefficients) @@ -331,7 +331,7 @@ setMethod("spark.logit", signature(data = "SparkDataFrame", formula = "formula") } if (!is.null(upperBoundsOnCoefficients)) { - if (class(upperBoundsOnCoefficients) != "matrix") { + if (is.matrix(upperBoundsOnCoefficients)) { stop("upperBoundsOnCoefficients must be a matrix.") } From 3ec7fca86073895cd675f71050a288af66bc7c05 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 3 Jun 2022 20:29:21 +0900 Subject: [PATCH 4/5] Apply suggestions from code review --- R/pkg/R/mllib_classification.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/pkg/R/mllib_classification.R b/R/pkg/R/mllib_classification.R index 10fdac77244e9..7204f8bb7dff4 100644 --- a/R/pkg/R/mllib_classification.R +++ b/R/pkg/R/mllib_classification.R @@ -322,7 +322,7 @@ setMethod("spark.logit", signature(data = "SparkDataFrame", formula = "formula") } if (!is.null(lowerBoundsOnCoefficients)) { - if (is.matrix(lowerBoundsOnCoefficients)) { + if (!is.matrix(lowerBoundsOnCoefficients)) { stop("lowerBoundsOnCoefficients must be a matrix.") } row <- nrow(lowerBoundsOnCoefficients) @@ -331,7 +331,7 @@ setMethod("spark.logit", signature(data = "SparkDataFrame", formula = "formula") } if (!is.null(upperBoundsOnCoefficients)) { - if (is.matrix(upperBoundsOnCoefficients)) { + if (!is.matrix(upperBoundsOnCoefficients)) { stop("upperBoundsOnCoefficients must be a matrix.") } From ddda6168b3f85f5efb3755559195730f8f2558da Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 3 Jun 2022 21:47:03 +0900 Subject: [PATCH 5/5] Fix --- R/pkg/R/serialize.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/pkg/R/serialize.R b/R/pkg/R/serialize.R index 7760d9be16f0b..85c318f30c338 100644 --- a/R/pkg/R/serialize.R +++ b/R/pkg/R/serialize.R @@ -58,7 +58,12 @@ writeObject <- function(con, object, writeType = TRUE) { # Checking types is needed here, since 'is.na' only handles atomic vectors, # lists and pairlists if (type %in% c("integer", "character", "logical", "double", "numeric")) { - if (is.na(object)) { + if (is.na(object[[1]])) { + # Uses the first element for now to keep the behavior same as R before + # 4.2.0. This is wrong because we should differenciate c(NA) from a + # single NA as the former means array(null) and the latter means null + # in Spark SQL. However, it requires non-trivial comparison to distinguish + # both in R. We should ideally fix this. object <- NULL type <- "NULL" }