Kontinuation commented on code in PR #91:
URL: https://github.com/apache/sedona-db/pull/91#discussion_r2352729004


##########
rust/sedona-spatial-join/src/optimizer.rs:
##########
@@ -2570,4 +2689,74 @@ mod tests {
         )
         .unwrap());
     }
+
+    #[test]
+    fn test_is_spatial_predicate() {
+        use datafusion_expr::ColumnarValue;
+        use datafusion_expr::{col, lit, Expr, ScalarUDF, SimpleScalarUDF};
+
+        // Test 1: ST_ functions should return true
+        let st_intersects_udf = create_dummy_st_intersects_udf();
+        let st_intersects_expr = 
Expr::ScalarFunction(datafusion_expr::expr::ScalarFunction {
+            func: st_intersects_udf,
+            args: vec![col("geom1"), col("geom2")],
+        });
+        assert!(super::is_spatial_predicate(&st_intersects_expr));
+
+        // ST_Distance(geom1, geom2) < 100 should return true
+        let st_distance_udf = create_dummy_st_distance_udf();
+        let st_distance_expr = 
Expr::ScalarFunction(datafusion_expr::expr::ScalarFunction {
+            func: st_distance_udf,
+            args: vec![col("geom1"), col("geom2")],
+        });
+        let distance_lt_expr = 
Expr::BinaryExpr(datafusion_expr::expr::BinaryExpr {
+            left: Box::new(st_distance_expr.clone()),
+            op: Operator::Lt,
+            right: Box::new(lit(100.0)),
+        });
+        assert!(super::is_spatial_predicate(&distance_lt_expr));
+
+        // ST_Distance(geom1, geom2) > 100 should return false
+        let distance_gt_expr = 
Expr::BinaryExpr(datafusion_expr::expr::BinaryExpr {
+            left: Box::new(st_distance_expr.clone()),
+            op: Operator::Gt, // Should be Lt/LtEq for left side

Review Comment:
   This comment indeed looks confusing. Idecide to remove this comment, since 
the comment on line 2719 is already pretty clear.



##########
rust/sedona-spatial-join/src/optimizer.rs:
##########
@@ -2570,4 +2689,74 @@ mod tests {
         )
         .unwrap());
     }
+
+    #[test]
+    fn test_is_spatial_predicate() {
+        use datafusion_expr::ColumnarValue;
+        use datafusion_expr::{col, lit, Expr, ScalarUDF, SimpleScalarUDF};
+
+        // Test 1: ST_ functions should return true
+        let st_intersects_udf = create_dummy_st_intersects_udf();
+        let st_intersects_expr = 
Expr::ScalarFunction(datafusion_expr::expr::ScalarFunction {
+            func: st_intersects_udf,
+            args: vec![col("geom1"), col("geom2")],
+        });
+        assert!(super::is_spatial_predicate(&st_intersects_expr));
+
+        // ST_Distance(geom1, geom2) < 100 should return true
+        let st_distance_udf = create_dummy_st_distance_udf();
+        let st_distance_expr = 
Expr::ScalarFunction(datafusion_expr::expr::ScalarFunction {
+            func: st_distance_udf,
+            args: vec![col("geom1"), col("geom2")],
+        });
+        let distance_lt_expr = 
Expr::BinaryExpr(datafusion_expr::expr::BinaryExpr {
+            left: Box::new(st_distance_expr.clone()),
+            op: Operator::Lt,
+            right: Box::new(lit(100.0)),
+        });
+        assert!(super::is_spatial_predicate(&distance_lt_expr));
+
+        // ST_Distance(geom1, geom2) > 100 should return false
+        let distance_gt_expr = 
Expr::BinaryExpr(datafusion_expr::expr::BinaryExpr {
+            left: Box::new(st_distance_expr.clone()),
+            op: Operator::Gt, // Should be Lt/LtEq for left side

Review Comment:
   This comment indeed looks confusing. I decide to remove this comment, since 
the comment on line 2719 is already pretty clear.



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

Reply via email to