Conversation
This branch has not been deployed
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?
Yes, I read the Contributor Rules and Contributor Development Guide.
Is this PR related to a ticket?
Closes #3124.
What changes were proposed in this PR?
Sedona's UDT columns cannot be passed directly to Spark 4.2's native spatial functions. This adds a Spark 4.2 build that exposes native GEOMETRY/GEOGRAPHY columns, while older Spark builds retain their existing UDT contract.
Spark owns ST_AsBinary, ST_GeomFromWKB, ST_GeogFromWKB, ST_SRID, and ST_SetSRID on 4.2. Sedona preserves those registrations and delegates its existing wrappers to Spark, including the geography constructor's native 4326 default.
The native build adapts Sedona's computational expressions at their inputs and outputs. It preserves aggregate and generator identity, nested spatial results, nulls, SRIDs, dimensional WKB, and public expression names. The same boundary applies to file formats, RDD adapters, box casts, spatial filter pushdown, and SQL clustering. Adjacent Sedona calls avoid intermediate serialization. Python uses PySpark spatial types with explicit Shapely conversion and updated GeoPandas, GeoArrow, and vectorized UDF boundaries. Existing UDT-backed data remains readable and can be converted through EWKB.
The bridge reads and writes Spark's SRID-prefixed ISO WKB directly. Output validation happens while writing JTS coordinates; input validation reads the native buffer without constructing Spark geometry objects. JTS receives the correct SRID factory on its first parse, and lazy geography values own their payload after a source row is reused. This removes redundant WKB rewrites and geometry copies while preserving Spark's dimensional, coordinate, ring, geography-bound, and SRID checks. Spark's own function and encoder implementations remain unchanged.
The migration guide documents signatures, SRID validation, native Python values, and fixed versus mixed SRID persistence. Spark 4.2.0's default columnar cache still rejects native spatial columns; DBSCAN caches vertex IDs for its internal graph cache. General native DataFrame caching remains a Spark limitation. Mixed-dimensional collections follow Spark's rejection contract.
How was this patch tested?
Latest Java 17 verification:
mvn -B -ntp -Dspark=4.2 -Dscala=2.13 -pl spark/spark-4.2 -am -Dmaven.test.skip=true -DskipTests -Dmaven.javadoc.skip=true install— passed.mvn -B -ntp -Dspark=4.2 -Dscala=2.13 -pl spark/spark-4.2 test— 62 passed across 10 suites.mvn -B -ntp -Dspark=4.2 -Dscala=2.13 -pl spark/common test -Dsuites=org.apache.sedona.sql.UDF.NativeFunctionRegistrationTest -Dtest=NativeFunctionRegistrationTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false— 9 passed; one legacy-only case canceled as intended.git diff --check, and independent source review passed. The full repository suite was not run locally.JMH 1.37 geometry SerDe rerun: Java 17.0.13, ARM64, one thread, two forks, 3 x 500 ms warmup and 5 x 500 ms measurement per fork, fixed 1 GiB heap, ActiveProcessorCount=2, GC profiler. Same input geometries (XY, SRID 4326) and benchmark sources as the previous run. Times are mean microseconds per operation; these measure JTS-to-representation boundaries, not complete Spark queries.
Encoding improved 3.7-15.5x; line decoding improved about 2x. MultiPoint decoding has wide confidence intervals overlapping the earlier baseline, so its lower mean is not a reliable speedup claim. Large-geometry allocation fell by approximately 64-91%. Unchanged custom-serializer controls remained close to their earlier results. Spark 4.0.2 UDT is still faster, especially at decoding. The 4.0 control uses the existing Sedona snapshot UDT wrapper with the same current common serializer, rather than a fresh full Spark 4.0 build.
Earlier branch validation (before the latest native codec optimization): Spark 3.5.8 registration/GeoStats (19 passed) and GeoParquet (6 passed); the original Python spatial-index failure (1 passed); Spark 4.1.2/3.5.4 UDT registration and file-format checks; Python Classic native/GeoArrow (30 passed) and actual local Spark Connect (22 passed); Spark 4.1 UDT Parquet migration to 4.2 with geography collections and XYZM geometry. Older Python GeoArrow (8 passed) and vectorized UDF checks (7 passed) also passed. Four broader GeoPandas dimension failures reproduced unchanged against the released 1.9.1 artifact. Those older/Python checks were not rerun for the native-only codec implementation.
Did this PR include necessary documentation updates?
Yes: a Spark 4.2 migration guide, Python conversion examples, Maven coordinates, and navigation links.