You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "james-willis (via GitHub)" <gi...@apache.org> on 2026/09/04 21:02:29 UTC

Re: [PR] feat(rust/sedona-expr): parse logical spatial filters [sedona-db]

james-willis commented on code in PR #1207:
URL: https://github.com/apache/sedona-db/pull/1207#discussion_r3937863131


##########
rust/sedona-expr/src/spatial_filter.rs:
##########
@@ -488,6 +499,83 @@ impl SpatialFilterFactory {
     }
 }
 
+/// Convert the small logical-expression subset understood by the spatial filter
+/// parser to its physical counterparts. This keeps logical and physical parsing
+/// on the same implementation path.
+fn logical_to_physical_expr(expr: &Expr) -> Result<Arc<dyn PhysicalExpr>> {
+    match expr {
+        Expr::Column(column) => Ok(Arc::new(Column::new(&column.name, 0))),
+        Expr::Literal(value, metadata) => Ok(Arc::new(Literal::new_with_metadata(
+            value.clone(),
+            metadata.clone(),
+        ))),
+        Expr::BinaryExpr(binary) => Ok(Arc::new(BinaryExpr::new(
+            logical_to_physical_expr(&binary.left)?,
+            binary.op,
+            logical_to_physical_expr(&binary.right)?,
+        ))),
+        Expr::ScalarFunction(function) => {
+            let args = function
+                .args
+                .iter()
+                .map(logical_to_physical_expr)
+                .collect::<Result<Vec<_>>>()?;
+            let return_type = if function.func.name() == "st_distance" {
+                DataType::Float64
+            } else {
+                DataType::Boolean
+            };
+            Ok(Arc::new(ScalarFunctionExpr::new(
+                function.func.name(),
+                Arc::clone(&function.func),
+                args,
+                Arc::new(Field::new("", return_type, true)),
+                Arc::new(ConfigOptions::default()),
+            )))
+        }
+        // Preserve an unsupported node as a physical expression that the shared
+        // argument parser will classify as `Other`.
+        _ => Ok(Arc::new(UnknownSentinelExpr)),

Review Comment:
   what actually happens in this case?



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