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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]