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/06/11 07:51:39 UTC
[PR] [GH-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin [sedona]
jiayuasu opened a new pull request, #3043:
URL: https://github.com/apache/sedona/pull/3043
## Did you read the Contributor Guide?
- [x] Yes
## Is this PR related to a ticket?
- [x] Yes — closes [#3042](https://github.com/apache/sedona/issues/3042); follow-up to the Box3D EPIC ([#2973](https://github.com/apache/sedona/issues/2973)) and the Flink slices #3037 (foundation) and #3040 (accessors / ST_3DExtent).
## What changes were proposed in this PR?
Final Flink Box3D slice. Brings the Flink predicate surface to parity with Spark's Box3D predicates (consolidated into `ST_Intersects` / `ST_Contains` plus the standalone `ST_3DDWithin`).
- **`ST_Intersects` / `ST_Contains`**: Box3D `eval` overloads wrapping `Predicates.box3dIntersects` / `box3dContains`. Mirrors the Box2D overloads already on these classes.
- **`ST_3DDWithin`**: new scalar function with two overloads — `(Geometry, Geometry, Double)` → `dWithin3D` (missing Z folds to 0), and `(Box3D, Box3D, Double)` → `dWithin3D`. NULL-guarded like the Box overloads. Registered in `Catalog`.
## How was this patch tested?
- `PredicateTest.testIntersectsOnBox3D` / `testContainsOnBox3D` — XY-overlapping-but-Z-disjoint rows confirm the Z axis is enforced (not just an XY-footprint check).
- `PredicateTest.test3DDWithin` — Geometry POINT Z within / just-outside the threshold, plus Box3D-on-Box3D faces-apart-in-Z within / just-outside.
- Full `PredicateTest`: 21 pass.
## Did this PR include necessary documentation updates?
- [x] No — Box3D documentation is tracked separately under the Box3D EPIC.
## Completion
This completes Flink Box3D parity with the shipped Spark surface: type + serializer, constructors, accessors, `ST_AsText`, `ST_3DExtent`, and predicates.
--
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-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #3043:
URL: https://github.com/apache/sedona/pull/3043#issuecomment-4685222624
One thing to fix before merge: `ST_3DDWithin` guards the spatial arguments, but not the nullable `distance` argument. Both overloads accept `Double` and then pass it to `org.apache.sedona.common.Predicates.dWithin3D(..., double)`, so `ST_3DDWithin(..., CAST(NULL AS DOUBLE))` will autounbox and throw instead of returning SQL `NULL`.
Please add `distance == null` to both null guards and cover the null-distance case in `PredicateTest`. I verified the current focused test suite passes with:
```bash
mvn -pl flink -Dtest=PredicateTest test
```
--
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-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #3043:
URL: https://github.com/apache/sedona/pull/3043#discussion_r3400312987
##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, distance, useSphere);
}
}
+
+ public static class ST_3DDWithin extends ScalarFunction {
+
+ public ST_3DDWithin() {}
+
+ /** 3D Euclidean distance-within over two geometries (missing Z folds to 0). */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o1,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o2,
+ @DataTypeHint("Double") Double distance) {
+ if (o1 == null || o2 == null) return null;
Review Comment:
Fixed in latest push: the geometry overload now guards `distance == null` (alongside the existing o1/o2 null guards) and returns NULL. Added a NULL-distance assertion to PredicateTest.test3DDWithin. The pre-existing ST_DWithin has the same gap (NULL distance and NULL geometry both NPE); tracked separately in #3046 to keep this PR scoped to Box3D.
##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, distance, useSphere);
}
}
+
+ public static class ST_3DDWithin extends ScalarFunction {
+
+ public ST_3DDWithin() {}
+
+ /** 3D Euclidean distance-within over two geometries (missing Z folds to 0). */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o1,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o2,
+ @DataTypeHint("Double") Double distance) {
+ if (o1 == null || o2 == null) return null;
+ Geometry geom1 = (Geometry) o1;
+ Geometry geom2 = (Geometry) o2;
+ return org.apache.sedona.common.Predicates.dWithin3D(geom1, geom2, distance);
+ }
+
+ /** Closed-interval 3D distance test over two Box3D values. */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = Box3DTypeSerializer.class,
+ bridgedTo = Box3D.class)
+ Box3D a,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = Box3DTypeSerializer.class,
+ bridgedTo = Box3D.class)
+ Box3D b,
+ @DataTypeHint("Double") Double distance) {
+ if (a == null || b == null) return null;
Review Comment:
Fixed in latest push: the Box3D overload now guards `distance == null` and returns NULL, with a NULL-distance assertion added to the test. See #3046 for the parallel ST_DWithin cleanup.
--
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-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin [sedona]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3043:
URL: https://github.com/apache/sedona/pull/3043#discussion_r3397829530
##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, distance, useSphere);
}
}
+
+ public static class ST_3DDWithin extends ScalarFunction {
+
+ public ST_3DDWithin() {}
+
+ /** 3D Euclidean distance-within over two geometries (missing Z folds to 0). */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o1,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o2,
+ @DataTypeHint("Double") Double distance) {
+ if (o1 == null || o2 == null) return null;
Review Comment:
`distance` can be NULL in SQL; both overloads pass it to `org.apache.sedona.common.Predicates.dWithin3D(..., double)` which will autounbox the `Double` and throw a NullPointerException. If Sedona intends SQL NULL-propagation here (as with the other arguments), guard `distance == null` and return null.
##########
flink/src/main/java/org/apache/sedona/flink/expressions/Predicates.java:
##########
@@ -405,4 +441,47 @@ public Boolean eval(
return org.apache.sedona.common.Predicates.dWithin(geom1, geom2, distance, useSphere);
}
}
+
+ public static class ST_3DDWithin extends ScalarFunction {
+
+ public ST_3DDWithin() {}
+
+ /** 3D Euclidean distance-within over two geometries (missing Z folds to 0). */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o1,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = GeometryTypeSerializer.class,
+ bridgedTo = Geometry.class)
+ Object o2,
+ @DataTypeHint("Double") Double distance) {
+ if (o1 == null || o2 == null) return null;
+ Geometry geom1 = (Geometry) o1;
+ Geometry geom2 = (Geometry) o2;
+ return org.apache.sedona.common.Predicates.dWithin3D(geom1, geom2, distance);
+ }
+
+ /** Closed-interval 3D distance test over two Box3D values. */
+ @DataTypeHint("Boolean")
+ public Boolean eval(
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = Box3DTypeSerializer.class,
+ bridgedTo = Box3D.class)
+ Box3D a,
+ @DataTypeHint(
+ value = "RAW",
+ rawSerializer = Box3DTypeSerializer.class,
+ bridgedTo = Box3D.class)
+ Box3D b,
+ @DataTypeHint("Double") Double distance) {
+ if (a == null || b == null) return null;
Review Comment:
`distance` can be NULL in SQL; this overload passes it to `Predicates.dWithin3D(Box3D, Box3D, double)` which will autounbox and throw a NullPointerException. Consider returning NULL when `distance` is NULL for consistent SQL null semantics.
--
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-3042] Flink Box3D predicates: ST_Intersects / ST_Contains + ST_3DDWithin [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #3043:
URL: https://github.com/apache/sedona/pull/3043
--
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