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

   ### Is your feature request related to a problem or challenge?
   
   Step forward to #4628 
   
   I found that we need to clone plan if analyzer has context error
   
   
https://github.com/apache/datafusion/blob/08c5345e932f1c5c948751e0d06b1fd99e174efa/datafusion/core/src/execution/session_state.rs#L689
   
   
https://github.com/apache/datafusion/blob/08c5345e932f1c5c948751e0d06b1fd99e174efa/datafusion/core/src/execution/session_state.rs#L706
   
   
https://github.com/apache/datafusion/blob/08c5345e932f1c5c948751e0d06b1fd99e174efa/datafusion/core/src/execution/session_state.rs#L735
   
   To avoid cloning, we need to preserve original logical plan in analzyer.
   
   ### Describe the solution you'd like
   
   Introduce AnalyzerResult  for analyzer check to preserve logical plan
   
   ```rust
   AnalyzerResult(LogicalPlan)
   ContextError(LogicalPlan, DatafusionError) // Original plan and context error
   Err(DatafusionError) // Other error
   ```
   
   It seems we need to modify trait for this approach
   ```rust
   pub trait AnalyzerRule {
       /// Rewrite `plan`
       fn analyze(&self, plan: LogicalPlan, config: &ConfigOptions) -> 
Result<LogicalPlan>;
   
      // New one
      fn analyze(&self, plan: LogicalPlan, config: &ConfigOptions) -> 
AnalyzerResult;
   
       /// A human readable name for this analyzer rule
       fn name(&self) -> &str;
   }
   ```
   
   ### Describe alternatives you've considered
   
   Alternative approach is deep clone if analyzer failed, it is not a bad idea 
if failing is rare.
   
   ### 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: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to