[GH-3260] Preserve M and ZM in Python GeometryUDT serialization - #3265
Open
jiayuasu wants to merge 2 commits into
Open
[GH-3260] Preserve M and ZM in Python GeometryUDT serialization#3265jiayuasu wants to merge 2 commits into
jiayuasu wants to merge 2 commits into
Conversation
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.Part of #3260.
Context and background
Sedona's Python GeometryUDT serializer is the boundary used to move Shapely
geometries into Spark/JVM geometry values. The native serializer previously
derived the coordinate layout only from the coordinate dimension and treated
every layout with at least three ordinates as XYZ. Its measure flag was always
false.
That behavior is sufficient for XY and ordinary XYZ geometries, but it cannot
distinguish the layouts introduced by modern Shapely and GEOS:
This is observable data loss, not only a type-label difference. For example,
two geometries that differ only in their M ordinates can become indistinguishable
after Python-to-JVM serialization. That makes it impossible for the distributed
geom_equals_identicalwork in #3260 to honor GeoPandas' requirement to compareevery stored coordinate dimension. It can also affect any other workflow that
constructs a Sedona geometry column from Shapely M or ZM objects.
GEOS added
GEOSHasM_rin version 3.12. Sedona still supports Shapely buildslinked against older GEOS versions, so requiring that symbol would prevent the
native extension from loading in supported environments. This PR therefore
loads
GEOSHasM_ras an optional symbol: newer GEOS versions preserve M/ZM,while older versions continue to support their existing XY/XYZ inputs. The Z
fallback also preserves XYZ when older GEOS versions report no Z because the
first Z ordinate is NaN.
The pure-Python serializer does not have a representation that can safely
preserve M. It now raises a clear error for M/ZM serialization and
deserialization instead of silently reinterpreting M as Z or dropping it.
What changes were proposed in this PR?
GEOSHasM_rAPI while retaining compatibility with older supported GEOS versions.This is the first PR in the #3260 stack and is based on
master:ST_EqualsIdenticalacross Sedona SQL enginesgeom_equals_identicalHow was this patch tested?
git diff --check, passed.Did this PR include necessary documentation updates?