andygrove opened a new issue, #11873:
URL: https://github.com/apache/datafusion/issues/11873

   ### Is your feature request related to a problem or challenge?
   
   In DataFusion Comet, we are mapping Spark's physical plan to a DataFusion 
physical plan. I would like to be able to apply DataFusion's physical optimizer 
rules to this plan but there does not seem to be a public API for this and I 
could not find an example.
   
   There is a public API in `DefaultPhysicalPlanner` to create an optimized 
physical plan from a logical plan:
   
   ```rust
   /// Create a physical plan from a logical plan
   async fn create_physical_plan(
       &self,
       logical_plan: &LogicalPlan,
       session_state: &SessionState,
   ) -> Result<Arc<dyn ExecutionPlan>> {
   ```
   
   This calls the optimizer internally:
   
   ```rust
   let plan = self
       .create_initial_plan(logical_plan, session_state)
       .await?;
   
   self.optimize_internal(plan, session_state, |_, _| {})
   ```
   
   The `optimize_internal` method seems to be what I need:
   
   ```rust
   /// Optimize a physical plan by applying each physical optimizer,
   /// calling observer(plan, optimizer after each one)
   fn optimize_internal<F>(
       &self,
       plan: Arc<dyn ExecutionPlan>,
       session_state: &SessionState,
       mut observer: F,
   ) -> Result<Arc<dyn ExecutionPlan>>
   ```
   
   
   ### Describe the solution you'd like
   
   I would like to make `optimize_internal` public and change the name to 
something like `optimize_physical_plan`.
   
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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

Reply via email to