You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "jiayuasu (via GitHub)" <gi...@apache.org> on 2026/10/13 06:52:07 UTC

[PR] [GH-3453] Return NULL from Snowflake ST_Distance and ST_HausdorffDistance for empty geometries [sedona]

jiayuasu opened a new pull request, #3454:
URL: https://github.com/apache/sedona/pull/3454

   ## 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 #3453
   
   ## What changes were proposed in this PR?
   
   The Snowflake UDFs `ST_Distance` and `ST_HausdorffDistance` (both overloads, in `UDFs` and `UDFsV2`) were declared to return a primitive `double`, but the functions they call return null when either geometry is empty, so the unboxing threw a `NullPointerException` instead of returning NULL as the Spark and Flink functions do.
   
   - Return `Double` from these six UDF methods. The generated Snowflake return type stays `DOUBLE`.
   - A bytecode scan of both UDF classes for unboxing calls finds no other UDF that unboxes a nullable result: `ST_NRings` unboxes an `Integer` that is never null.
   - Docs: `ST_HausdorffDistance` (SQL, Flink and Snowflake) said an empty geometry gives 0.0, but it has returned NULL since #2730, as `FunctionsTest` and the Spark tests expect. `ST_Distance` now documents NULL for an empty geometry too.
   
   ## How was this patch tested?
   
   - New `EmptyGeometryDistanceTest` calls the `UDFs` (WKB) and `UDFsV2` (GeoJSON) methods with an empty geometry. It fails with the `NullPointerException` before the change and passes after; the `snowflake` module's 5 tests pass.
   - Added NULL assertions for an empty geometry to `test_ST_Distance` and `test_ST_HausdorffDistance` in `snowflake-tester`'s `TestFunctions`. They compile (`-Psnowflake`) and run in the Snowflake integration CI.
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I have updated the documentation.


-- 
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-3453] Return NULL from Snowflake ST_Distance and ST_HausdorffDistance for empty geometries [sedona]

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


-- 
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