You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "james-willis (via GitHub)" <gi...@apache.org> on 2026/09/25 20:49:25 UTC

[PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

james-willis opened a new pull request, #3404:
URL: https://github.com/apache/sedona/pull/3404

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/)
   
   ## Is this PR related to a ticket?
   
   - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #3403
   
   ## What changes were proposed in this PR?
   
   Make the four functions that read an ordinal 0-based agree with PostGIS, which is 1-based for all of them. This is a breaking change, aimed at 2.0.
   
   | Function | Before | After (= PostGIS) |
   |---|---|---|
   | `ST_GeometryN(g, n)` | `n = 0` is the first geometry | `n = 1` is the first; `0`, negatives and `n > N` return null |
   | `ST_InteriorRingN(p, n)` | `n = 0` is the first hole | `n = 1` is the first; `0`, negatives and `n > N` return null |
   | `RS_Value(raster, colX, rowY, band)` | `(0, 0)` is the upper-left pixel | `(1, 1)` is the upper-left pixel, as in `ST_Value` |
   | `RS_Values(raster, xs, ys, band)` | same as `RS_Value` | same as `RS_Value` |
   
   On the raster side this also removes an internal inconsistency: `RS_PixelAsPoint`/`Centroid`/`Polygon`, `RS_SetValue(s)` and `RS_RasterToWorldCoord`/`RS_WorldToRasterCoord` were already 1-based, and `RS_Value(raster, colX, rowY, band)` mixed 0-based pixels with a 1-based band in one signature.
   
   **Deliberately unchanged:** `ST_AddPoint`, `ST_SetPoint` and `ST_RemovePoint` are 0-based in PostGIS, and Sedona already matches. `ST_PointN` and all band arguments were already 1-based. The point-geometry forms of `RS_Value`/`RS_Values` are unaffected.
   
   PostGIS 3.6.4 behaviour was measured directly for every function above, not taken from its docs.
   
   Other callers updated so their own semantics don't change:
   - `GeoSeries.get_geometry` keeps GeoPandas' 0-based and negative indexing by adding 1 before calling `ST_GeometryN`.
   - `GeoSeries.interiors` and coverage simplification iterate rings `1..N`.
   - The Python `ST_GeometryN`/`ST_InteriorRingN` wrappers now reject integer `n < 1` instead of `n < 0`.
   - OGC conformance tests T29 (`ST_InteriorRingN`) and T31 (`ST_GeometryN`) were `ignore`d "because Sedona is 0 indexed" and are re-enabled.
   
   ## How was this patch tested?
   
   - New `common` unit tests pin the PostGIS boundaries for `geometryN`/`interiorRingN`: `1` and `N` return elements; `0`, `-1` and `N + 1` return null; a non-collection returns itself only at `1`. `RS_Value` gains cases for column 0 and row 0 returning null.
   - Existing Java, Scala, Python, R, Flink and Snowflake tests shift each index by one and keep their expected values, so they still assert the same element.
   - Run locally (JDK 17):
     - `common`: `FunctionsTest` plus the `raster.*Test` suites, 717 tests passing.
     - `spark/common`: `functionTestScala`, `dataFrameAPITestScala`, `PreserveSRIDSuite` and `GeometryTypesAndFunctionsTestScala` (635 passing, including the re-enabled T29/T31), plus `rasteralgebraTest` and `netcdfMetadataTest` (240 passing).
   - Not run locally: the Python, R, Flink and Snowflake suites. They rely on CI.
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I have updated the documentation. The SQL, Flink and Snowflake pages for `ST_GeometryN`/`ST_InteriorRingN`, plus `RS_Value`/`RS_Values`, say the index is 1-based since `v2.0.0`. Examples and the `ST_SharedPaths` examples are shifted, and the two SVG diagrams are relabelled.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5879218193

   If no objectsion by tomorrow I will merge with Dewy's approval
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5840266402

   The failing Java checks are unrelated to this change. In every failing job, only two tests fail: `GeoPackageReaderTest` "should be able to read files from S3" and `OsmReaderTest` "should be able to read from osm file on s3". Every other test passes, including all of the ordinal changes (for example 2,241 passing in the Spark 4.1 job).
   
   Both tests start a Testcontainers MinIO container pinned to `quay.io/minio/minio:RELEASE.2025-09-07T16-13-09Z`, and that image is no longer pullable. The quay.io tag reports "no such manifest", the quay.io repository refuses anonymous pulls (even `latest`), and Docker Hub's `minio/minio` is refused too. So the pull times out with `ContainerFetchException: Can't get Docker image`.
   
   This affects every Java CI run on the repo since 2026-09-24, across several unrelated PRs; the last green `master` run was 2026-09-23. A fix to replace the image is being prepared as a separate PR. Once it lands, re-running these checks should pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5915910098

   The decision is to not include any flag. Users can toggle this behavior by toggling which version of sedona they use.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis merged PR #3404:
URL: https://github.com/apache/sedona/pull/3404


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5906075460

   What is our decision on this? Give up the postgis behavior compatibility based on what we discussed before


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5843363060

   should we introduce a postgis compatible flag? like what Spark's ANSI sql flag?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5846859177

   Maybe if there's more cases than just this one? I think in general we are postgis compatible and if we're not it's a bug on our end (or because we reported a bug in PostGIS, like for geometrycollection perimeters in the geography type).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [GH-3403] Make ST_GeometryN, ST_InteriorRingN, RS_Value and RS_Values 1-based to match PostGIS [sedona]

Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on PR #3404:
URL: https://github.com/apache/sedona/pull/3404#issuecomment-5859906783

   I will add a flag to this pr. But it makes me wonder if I should be steering the 2.0.0 migration guide here as well


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org