Repository navigation
[GH-3338] Support Spark 4.x in the R interface - #3340
Merged
Merged
Conversation
spark_dependencies() only accepted Spark major version 3 and defaulted the Scala suffix to 2.12, so spark_connect() on Spark 4.x stopped with "Unsupported Spark version" before any jar was considered. Accept Spark 4.x and pin its Scala suffix to 2.13: Spark 4 and Sedona Spark 4 artifacts are Scala 2.13 only, while sparklyr still hands extensions 2.12 for every Spark release at or above 3.0. Add unit tests for the artifact selection and a Spark 4.0.2 / Java 17 entry to the R CI matrix.
…ackend The sparklyr backend for Spark 3 unwraps java.util.List results that wrap a Scala Seq (JavaRDD.take/collect, KNNQuery) into R lists; the backend for Spark 4 hands them back as a single Java object. Normalise on the JVM side with toArray so sedona_knn_query() and sedona_range_query() return the same shape on both, accept an already-Java list when building the result RDD, and make the two tests that index take()/takeOrdered() results use toArray like the neighbouring tests already do.
Use one include entry per Spark/Scala/Java/R combination, as the Java and Python workflows do, instead of a cross product patched with an extra entry. Add Spark 4.1.1 alongside 4.0.2 and fold the constant Hadoop version into the job environment.
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes R interface rejects Spark 4.x with "Unsupported Spark version" #3338What changes were proposed in this PR?
spark_dependencies()inR/R/dependencies.Ronly accepted Spark major version 3 and defaulted the Scala suffix to2.12, sospark_connect()on Spark 4.x failed withUnsupported Spark version: 4.0before any jar or Maven coordinate was considered.2.13. Pinning is deliberate: sparklyr 1.9.5 hands every extensionscala_version = "2.12"for any Spark release at or above 3.0, so honouring that value would request the non-existentsedona-spark-shaded-4.0_2.12. Spark 4 and Sedona's Spark 4 artifacts are Scala 2.13 only. Spark 3.x keeps the previous behaviour (2.12unless a Scala version is passed), and Spark 2.x and earlier are still rejected.R/DESCRIPTION:SystemRequirementsnow reads Spark 3.x or 4.x.R/tests/testthat/test-dependencies.R: unit tests for the artifact selection (Spark 3.5 ->3.5_2.12; Spark 4.0 with2.12passed in ->4.0_2.13; Spark 4.1 ->4.1_2.13; Spark 2.4 rejected;SEDONA_JAR_FILESswaps the Sedona coordinate for local jars). They run without a Spark connection..github/workflows/r.yml: list the matrix explicitly, one entry per Spark/Scala/Java/R combination like the Java and Python workflows, and add Spark 4.0.2 and 4.1.1 (Scala 2.13.16, Java 17) so the R test suite also runs on Spark 4.R/R/spatial_queries.R: the sparklyr backend for Spark 3 unwrapsjava.util.Listresults that wrap a ScalaSeq(JavaRDD.take(),collect(),KNNQuery) into R lists, while the backend for Spark 4 returns them as a single Java object.sedona_knn_query()andsedona_range_query()now convert on the JVM side withtoArray, soresult_type = "raw"returns an R list of geometries on both backends, and the KNN result RDD is built from the Java list directly when that is what came back. Two tests that indextake()/takeOrdered()results now calltoArraylike the neighbouring tests already do.How was this patch tested?
4.0_2.13build and the connection worked; 6 of 267 tests failed because of the Java list serialisation difference described above, which the second commit addresses.emr-spark-8.0.0(Spark 4.0.2, Scala 2.13.16, Java 17) with sparklyr 1.9.5: the CRAN 1.9.1 package fails withUnsupported Spark version: 4.0. With this patch installed from source,spark_connect(master = "yarn", spark_home = "/usr/lib/spark")connects both withSEDONA_JAR_FILESpointing atsedona-spark-shaded-4.0_2.13-1.9.1.jarand with it unset, in which case Maven resolvesorg.apache.sedona:sedona-spark-shaded-4.0_2.13:1.9.1.ST_Point,ST_Transformand an executor-side aggregation over 100k points return correct results.Did this PR include necessary documentation updates?