goldmedal commented on code in PR #20548:
URL: https://github.com/apache/datafusion/pull/20548#discussion_r2867536702
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -157,6 +157,26 @@ pub trait ExtensionPlanner {
physical_inputs: &[Arc<dyn ExecutionPlan>],
session_state: &SessionState,
) -> Result<Option<Arc<dyn ExecutionPlan>>>;
+
+ /// Create a physical plan for a [`LogicalPlan::TableScan`].
+ ///
+ /// This is useful for planning valid [`TableSource`]s that are not
[`TableProvider`]s.
+ ///
Review Comment:
It would be great to add a simple example for this method. Something like:
```suggestion
/// # Example
///
/// ```rust,ignore
/// use std::sync::Arc;
/// use datafusion::physical_plan::ExecutionPlan;
/// use datafusion::logical_expr::TableScan;
/// use datafusion::execution::context::SessionState;
/// use datafusion::error::Result;
/// use datafusion_physical_planner::{ExtensionPlanner, PhysicalPlanner};
/// use async_trait::async_trait;
///
/// // Your custom table source type
/// struct MyCustomTableSource { /* ... */ }
///
/// // Your custom execution plan
/// struct MyCustomExec { /* ... */ }
///
/// struct MyExtensionPlanner;
///
/// #[async_trait]
/// impl ExtensionPlanner for MyExtensionPlanner {
/// async fn plan_extension(
/// &self,
/// _planner: &dyn PhysicalPlanner,
/// _node: &dyn UserDefinedLogicalNode,
/// _logical_inputs: &[&LogicalPlan],
/// _physical_inputs: &[Arc<dyn ExecutionPlan>],
/// _session_state: &SessionState,
/// ) -> Result<Option<Arc<dyn ExecutionPlan>>> {
/// Ok(None)
/// }
///
/// async fn plan_table_scan(
/// &self,
/// _planner: &dyn PhysicalPlanner,
/// scan: &TableScan,
/// _session_state: &SessionState,
/// ) -> Result<Option<Arc<dyn ExecutionPlan>>> {
/// // Check if this is your custom table source
/// if scan.source.as_any().is::<MyCustomTableSource>() {
/// // Create a custom execution plan for your table source
/// let exec = MyCustomExec::new(
/// scan.table_name.clone(),
/// Arc::clone(scan.projected_schema.inner()),
/// );
/// Ok(Some(Arc::new(exec)))
/// } else {
/// // Return None to let other extension planners handle it
/// Ok(None)
/// }
/// }
/// }
/// ```
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]