Skip to content

Comments

fix(rust/sedona-functions): propagate NULL for scalar NULL SRID/CRS in ST_SetSRID/ST_SetCRS#629

Merged
Kontinuation merged 1 commit intoapache:mainfrom
Kontinuation:fix-setsrid-with-null-scalar
Feb 18, 2026
Merged

fix(rust/sedona-functions): propagate NULL for scalar NULL SRID/CRS in ST_SetSRID/ST_SetCRS#629
Kontinuation merged 1 commit intoapache:mainfrom
Kontinuation:fix-setsrid-with-null-scalar

Conversation

@Kontinuation
Copy link
Member

@Kontinuation Kontinuation commented Feb 17, 2026

Rationale

ST_SetSRID should have consistent behavior regardless of whether the SRID arg is an array or not. Returning NULL when the input SRID is NULL identical to the behavior of ST_SetSRID in PostGIS.

Summary

  • Fix inconsistent NULL handling in ST_SetSRID and ST_SetCRS: scalar NULL SRID/CRS now returns NULL geometry instead of preserving the geometry with CRS unset, matching the existing array NULL behavior and standard SQL NULL propagation semantics.
  • Extract shared invoke_set_crs() helper to deduplicate identical logic between STSetSRID and STSetCRS kernels.
  • Update Rust unit tests and Python integration test to reflect the corrected behavior.

…n ST_SetSRID/ST_SetCRS

ST_SetSRID and ST_SetCRS behaved inconsistently for NULL SRID/CRS input:
scalar NULL preserved the geometry (just unset CRS), while array NULL
masked the geometry row as NULL. Fix the scalar path to also return
NULL, consistent with SQL NULL propagation semantics.
@Kontinuation Kontinuation force-pushed the fix-setsrid-with-null-scalar branch from 976cb8e to 2904ac9 Compare February 17, 2026 11:56
@Kontinuation Kontinuation marked this pull request as ready for review February 17, 2026 11:58
@Kontinuation Kontinuation requested a review from Copilot February 17, 2026 11:58
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 pull request fixes inconsistent NULL handling in ST_SetSRID and ST_SetCRS functions to match PostGIS behavior and standard SQL NULL propagation semantics.

Changes:

  • Fix scalar NULL SRID/CRS to propagate NULL geometry instead of preserving geometry with unset CRS
  • Extract shared invoke_set_crs() helper function to deduplicate logic between STSetSRID and STSetCRS
  • Update Rust unit tests and add Python integration test to validate the corrected NULL behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rust/sedona-functions/src/st_setsrid.rs Added new invoke_set_crs helper to handle NULL propagation consistently; refactored STSetSRID and STSetCRS to use shared logic; updated unit tests to verify NULL scalar returns NULL geometry
python/sedonadb/tests/functions/test_transforms.py Added integration test to verify NULL SRID produces NULL geometry, matching PostGIS behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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! The previous behaviour was definitely not intentional on my end 😬

@Kontinuation Kontinuation merged commit 1be99eb into apache:main Feb 18, 2026
23 checks passed
@paleolimbot paleolimbot added this to the 0.3.0 milestone Feb 19, 2026
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.

2 participants