[GH-3171][GH-3172] Fix empty polygon orientation and GeoSeries skew flags - #3173
Merged
jiayuasu merged 4 commits intoJul 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes edge-case handling for polygon orientation predicates across Sedona engines and aligns Sedona’s GeoPandas-compatible GeoSeries.skew(use_radians=...) behavior with GeoPandas by accepting integer “boolean-like” flags.
Changes:
- Make
ST_IsPolygonCW/ST_IsPolygonCCWreturntruefor emptyPOLYGON/MULTIPOLYGONinputs and avoidgetGeometryN(0)on empty multipolygons. - Expand
GeoSeries.skew(use_radians=...)to accept Python/NumPy integer scalars (while still rejecting non-integral values like floats). - Add/extend coverage (common, Spark, Flink, Snowflake, Python) and document empty-geometry semantics in SQL/Snowflake/Flink docs.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
common/src/main/java/org/apache/sedona/common/Functions.java |
Fixes orientation predicate logic for empty polygons/multipolygons and removes unsafe first-element access. |
common/src/test/java/org/apache/sedona/common/FunctionsTest.java |
Adds unit tests covering empty polygon/multipolygon and mixed multipolygon cases. |
spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala |
Adds Spark SQL test ensuring empty polygonal geometries return true for both predicates. |
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java |
Adds Flink SQL test for empty polygon/multipolygon orientation behavior. |
snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java |
Adds Snowflake V1 function tests for empty polygon/multipolygon orientation behavior. |
snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctionsV2.java |
Adds Snowflake V2 function tests for empty polygon/multipolygon orientation behavior. |
python/sedona/spark/sql/st_functions.py |
Updates Python SQL-function docstrings to document empty-geometry behavior consistently. |
python/sedona/spark/geopandas/geoseries.py |
Allows integer/NumPy-integer use_radians values and normalizes via bool(use_radians). |
python/tests/geopandas/test_geoseries.py |
Adds tests verifying integer use_radians parity with GeoPandas and adjusts invalid-case coverage to floats. |
docs/api/sql/Geometry-Accessors/ST_IsPolygonCW.md |
Documents POLYGON EMPTY / MULTIPOLYGON EMPTY returning true. |
docs/api/sql/Geometry-Accessors/ST_IsPolygonCCW.md |
Documents POLYGON EMPTY / MULTIPOLYGON EMPTY returning true. |
docs/api/flink/Geometry-Accessors/ST_IsPolygonCW.md |
Documents empty-geometry semantics for Flink docs. |
docs/api/flink/Geometry-Accessors/ST_IsPolygonCCW.md |
Documents empty-geometry semantics for Flink docs. |
docs/api/snowflake/vector-data/Geometry-Accessors/ST_IsPolygonCW.md |
Documents empty-geometry semantics for Snowflake docs. |
docs/api/snowflake/vector-data/Geometry-Accessors/ST_IsPolygonCCW.md |
Documents empty-geometry semantics for Snowflake docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #3171.
Closes #3172.
What changes were proposed in this PR?
PolygonandMultiPolygoninputs as vacuously true in bothST_IsPolygonCWandST_IsPolygonCCW.MultiPolygon, and treat empty members of mixed multipolygons as neutral.GeoSeries.skew(use_radians=...), matching GeoPandas truthiness behavior while retaining strict rejection of non-integral values.The orientation predicates previously accessed
getGeometryN(0)unconditionally for multipolygons and did not handle an empty polygon consistently. The GeoSeries method separately restricteduse_radiansto boolean scalar types even though GeoPandas also accepts integer boolean-like values.Full PostGIS parity for non-polygonal inputs and geometry collections is deferred to #3174 because it changes existing predicate results and should be handled at a major-version boundary.
How was this patch tested?
mvn -pl common -Dtest=FunctionsTest test(302 tests)functionTestScalasuite (235 tests)python -m pytest -q tests/geopandas/test_geoseries.py -k skew(20 tests)mvn -Dsnowflake=true -pl snowflake-tester -am -DskipTests packageDid this PR include necessary documentation updates?