Kontinuation commented on code in PR #735: URL: https://github.com/apache/sedona-db/pull/735#discussion_r3004906305
########## rust/sedona-query-planner/src/spatial_join_factory.rs: ########## @@ -0,0 +1,249 @@ +// 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. + +//! Extension planner for spatial join plan nodes. + +use std::collections::HashMap; +use std::sync::Arc; + +use async_trait::async_trait; + +use arrow_schema::Schema; + +use datafusion::config::ConfigOptions; +use datafusion::execution::session_state::SessionState; +use datafusion::physical_plan::ExecutionPlan; +use datafusion::physical_planner::{ExtensionPlanner, PhysicalPlanner}; +use datafusion_common::{plan_err, DFSchema, Result}; +use datafusion_expr::logical_plan::UserDefinedLogicalNode; +use datafusion_expr::{JoinType, LogicalPlan}; +use datafusion_physical_expr::create_physical_expr; +use datafusion_physical_plan::joins::utils::JoinFilter; +use datafusion_physical_plan::joins::NestedLoopJoinExec; +use sedona_common::option::SedonaOptions; +use sedona_common::{sedona_internal_err, SpatialJoinOptions}; + +use crate::logical_plan_node::SpatialJoinPlanNode; +use crate::spatial_expr_utils::transform_join_filter; +use crate::spatial_predicate::SpatialPredicate; + +/// Arguments passed to a [`SpatialJoinFactory`] when planning a spatial join. +pub struct PlanSpatialJoinArgs<'a> { + pub physical_left: &'a Arc<dyn ExecutionPlan>, + pub physical_right: &'a Arc<dyn ExecutionPlan>, + pub spatial_predicate: &'a SpatialPredicate, + pub remainder: Option<&'a JoinFilter>, + pub join_type: &'a JoinType, + pub join_options: &'a SpatialJoinOptions, + pub options: &'a Arc<ConfigOptions>, +} + +/// Factory trait for creating spatial join physical plans. +/// +/// Implementations decide whether they can handle a given spatial predicate and, +/// if so, produce an appropriate [`ExecutionPlan`]. +pub trait SpatialJoinFactory: std::fmt::Debug + Send + Sync { + /// Given the provided arguments, produce an [ExecutionPlan] implementing + /// the join operation or `None` if this implementation cannot execute the join + fn plan_spatial_join( + &self, + args: &PlanSpatialJoinArgs<'_>, + ) -> Result<Option<Arc<dyn ExecutionPlan>>>; +} Review Comment: I suggest renaming it to `SpatialJoinPhysicalPlanner` or `SpatialJoinPlanner` since the main function of this trait is producing physical plans. `SpatialJoinFactory` is a bit vague since there are lots of components related to spatial join. -- 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]
