Skip to content

Add Unset code for ST_SetSrid#16

Merged
jiayuasu merged 3 commits intoapache:mainfrom
jesspav:add_setsrid_0
Sep 4, 2025
Merged

Add Unset code for ST_SetSrid#16
jiayuasu merged 3 commits intoapache:mainfrom
jesspav:add_setsrid_0

Conversation

@jesspav
Copy link
Collaborator

@jesspav jesspav commented Sep 4, 2025

Summary

After this change, using code 0 in ST_SetSrid unsets the CRS.

Changes

Updated the UDF to check for the 0 code.

Testing

  • Added unit test
  • Added an integration test
  • Added additional integration tests for ST_SetSrid

Example

> select ST_SetSrid(ST_GeomFromText('POINT (1 1)'), 4326)
;
┌─────────────────────────────────────────────────────────────┐
│ st_setsrid(st_geomfromwkt(Utf8("POINT (1 1)")),Int64(4326)) │
│                       wkb <ogc:crs84>                       │
╞═════════════════════════════════════════════════════════════╡
│ POINT(1 1)                                                  │
└─────────────────────────────────────────────────────────────┘

1 row(s)/1 column(s) fetched. 
Elapsed 0.024 seconds.

> select ST_SetSrid(ST_SetSrid(ST_GeomFromText('POINT (1 1)'), 4326), 0);
┌──────────────────────────────────────────────────────────────────────────────────┐
│ st_setsrid(st_setsrid(st_geomfromwkt(Utf8("POINT (1 1)")),Int64(4326)),Int64(0)) │
│                                        wkb                                       │
╞══════════════════════════════════════════════════════════════════════════════════╡
│ POINT(1 1)                                                                       │
└──────────────────────────────────────────────────────────────────────────────────┘

@jesspav jesspav requested review from Copilot September 4, 2025 16:26

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to handle SRID code 0 as a special case in the ST_SetSRID function, where passing 0 will unset the coordinate reference system (CRS) of the geometry. This aligns with PostGIS behavior where SRID 0 indicates no spatial reference system.

  • Added logic to treat string "0" as a None CRS value in the ST_SetSRID function
  • Added comprehensive test coverage for both integer and string SRID inputs including the new 0 behavior
  • Added Python integration tests to verify the functionality works end-to-end

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust/sedona-functions/src/st_setsrid.rs Added conditional logic to handle "0" as unset CRS and unit test for integer 0 input
python/sedonadb/tests/functions/test_transforms.py Added comprehensive test cases for ST_SetSRID with various SRID inputs including 0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jesspav jesspav changed the title Add st_setsrid unset on code 0 Add Unset code for ST_SetSrid Sep 4, 2025
@jesspav jesspav requested a review from paleolimbot September 4, 2025 16:50
@jesspav jesspav marked this pull request as ready for review September 4, 2025 16:51
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jiayuasu jiayuasu merged commit 55be594 into apache:main Sep 4, 2025
5 checks passed
@jesspav jesspav deleted the add_setsrid_0 branch November 14, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants