Kontinuation commented on code in PR #562: URL: https://github.com/apache/sedona-db/pull/562#discussion_r2797512016
########## rust/sedona-spatial-join/src/planner/optimizer.rs: ########## @@ -0,0 +1,231 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +use std::sync::Arc; + +use crate::planner::logical_plan_node::SpatialJoinPlanNode; +use crate::planner::spatial_expr_utils::collect_spatial_predicate_names; +use crate::planner::spatial_expr_utils::is_spatial_predicate; +use datafusion::execution::session_state::SessionStateBuilder; +use datafusion::optimizer::{ApplyOrder, OptimizerConfig, OptimizerRule}; +use datafusion_common::tree_node::Transformed; +use datafusion_common::NullEquality; +use datafusion_common::Result; +use datafusion_expr::logical_plan::Extension; +use datafusion_expr::{BinaryExpr, Expr, Operator}; +use datafusion_expr::{Filter, Join, JoinType, LogicalPlan}; +use sedona_common::option::SedonaOptions; + +/// Register only the logical spatial join optimizer rule. +/// +/// This enables building `Join(filter=...)` from patterns like `Filter(CrossJoin)`. +/// It intentionally does not register any physical plan rewrite rules. +pub fn register_spatial_join_logical_optimizer( + session_state_builder: SessionStateBuilder, +) -> SessionStateBuilder { + session_state_builder + .with_optimizer_rule(Arc::new(MergeSpatialProjectionIntoJoin)) + .with_optimizer_rule(Arc::new(SpatialJoinLogicalRewrite)) Review Comment: No, this is not within the scope of this PR. We need to add some early stage passes to convert Join nodes for KNN join to something else even before the logical plan optimization starts. -- 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]
