paleolimbot commented on code in PR #641:
URL: https://github.com/apache/sedona-db/pull/641#discussion_r2833743974
##########
rust/sedona-spatial-join/src/planner/spatial_expr_utils.rs:
##########
@@ -2309,4 +2365,196 @@ mod tests {
let names = collect_spatial_predicate_names(&non_spatial_and);
assert!(names.is_empty());
}
+
+ #[test]
+ fn test_find_st_knn_call_simple() {
+ let st_knn_udf = create_dummy_st_knn_udf();
+ let expr = Expr::ScalarFunction(ScalarFunction {
+ func: st_knn_udf,
+ args: vec![col("l.geom"), col("r.geom"), lit(5i32), lit(false)],
+ });
+
+ let result = find_st_knn_call(&expr);
+ assert!(result.is_some());
+ assert_eq!(result.unwrap().func.name(), "st_knn");
+ }
+
+ #[test]
+ fn test_find_st_knn_call_nested_in_and() {
+ let st_knn_udf = create_dummy_st_knn_udf();
+ let knn_expr = Expr::ScalarFunction(ScalarFunction {
+ func: st_knn_udf,
+ args: vec![col("l.geom"), col("r.geom"), lit(5i32), lit(false)],
+ });
Review Comment:
`.call()` is probably a bit more compact since there are lot of these:
```suggestion
let knn_expr = st_knn_udf.call(vec![col("l.geom"), col("r.geom"),
lit(5i32), lit(false)]);
```
##########
rust/sedona-spatial-join/src/planner/spatial_expr_utils.rs:
##########
@@ -2309,4 +2365,196 @@ mod tests {
let names = collect_spatial_predicate_names(&non_spatial_and);
assert!(names.is_empty());
}
+
+ #[test]
+ fn test_find_st_knn_call_simple() {
+ let st_knn_udf = create_dummy_st_knn_udf();
+ let expr = Expr::ScalarFunction(ScalarFunction {
+ func: st_knn_udf,
+ args: vec![col("l.geom"), col("r.geom"), lit(5i32), lit(false)],
+ });
Review Comment:
Optional, but if you have datafusion as a dev dependency already you can
also use `ctx.parse_sql_expr()` to create these (might make it easier to spot
errors or create more complex test cases in the future).
--
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]