[GH-3046] Flink ST_DWithin: propagate NULL arguments instead of NPE#3047
Merged
Conversation
… NPE The Flink ST_DWithin overloads passed their arguments straight to the common-layer dWithin, which takes primitive double / boolean. A SQL NULL distance (or useSphere) autounboxed to a NullPointerException, and a NULL geometry NPE'd inside the predicate — instead of propagating to a NULL result as SQL semantics require. Surfaced reviewing apache#3043, where ST_3DDWithin was given the guards but ST_DWithin was left as-is to keep that PR scoped to Box3D. - 3-arg overload: guard o1 / o2 / distance. - 4-arg overload: additionally guard useSphere. Audit of the rest of the Flink predicate surface: ST_DWithin and ST_3DDWithin are the only predicates with boxed-primitive arguments (distance / useSphere); every other predicate takes geometry RAW arguments only, so there is no further autounbox hazard. ST_3DDWithin was already guarded in apache#3043. Tests: PredicateTest.testDWithinNullArguments asserts NULL propagation for a NULL distance, a NULL geometry, and a NULL useSphere.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes Flink ST_DWithin overloads to propagate SQL NULL inputs to a NULL result (instead of throwing NullPointerException due to autounboxing / null geometries), and adds regression coverage for these cases.
Changes:
- Add NULL-guarding in Flink
ST_DWithin3-arg overload foro1,o2, anddistance. - Add NULL-guarding in Flink
ST_DWithin4-arg overload foro1,o2,distance, anduseSphere. - Add a Flink
PredicateTestcovering NULL propagation for NULL distance, NULL geometry, and NULLuseSphere.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java | Adds explicit NULL checks to prevent NPEs from autounboxing / null geometry inputs and to follow SQL NULL semantics. |
| flink/src/test/java/org/apache/sedona/flink/PredicateTest.java | Adds regression test asserting ST_DWithin returns NULL when any argument is NULL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
10 tasks
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?
What changes were proposed in this PR?
The Flink
ST_DWithinoverloads passed their arguments straight to the common-layerdWithin, which takes primitivedouble/boolean. A SQLNULLdistance (oruseSphere) autounboxed to aNullPointerException, and aNULLgeometry NPE'd inside the predicate — instead of propagating to aNULLresult as SQL semantics require.o1/o2/distance.useSphere.This brings
ST_DWithinup to the NULL-safe contract thatST_3DDWithinalready has (added in #3043).Audit of the rest of the Flink predicate surface:
ST_DWithinandST_3DDWithinare the only predicates with boxed-primitive arguments (distance/useSphere); every other predicate takes geometry RAW arguments only, so there is no further autounbox hazard.ST_3DDWithinwas already guarded.How was this patch tested?
PredicateTest.testDWithinNullArgumentsasserts NULL propagation for a NULL distance, a NULL geometry, and a NULLuseSphere.PredicateTest: 22 pass.Did this PR include necessary documentation updates?