alamb commented on issue #9637:
URL: 
https://github.com/apache/arrow-datafusion/issues/9637#issuecomment-2002396168

   > @alamb I think being able to skip failed rules is the main challenge to 
rewriting the plan with ownership
   
   This is an excellent point
   
   > Instead of Transformed, I think we need to preserve the old data and fail 
state to mimic Err in Result but with old data
   
   If we need to preserve the old data, there is no choice but to copy the 
`LogicalPlan` on each pass 🤔 (well I guess there could be some way to repair 
the partially rewritten plan, but that sounds very compliated). 
   
   Since `skip_failed_rules` is `false`  by default:
   
   
https://github.com/apache/arrow-datafusion/blob/dcfe70987e98da0410146b5e1292ab20f3f118e0/datafusion/common/src/config.rs#L549
   
   Could we maybe only do the copy when `skip_failed_rules` is enabled? 
Something like this:
   
   ```rust
   if skip_failed_rules {
     let original_plan = plan.clone();
     let new_plan = optimizer.try_optimize_owned(plan)
      .ok_or_else(|e| original_plan);
   } else {
     optimizer.try_optimize_owned(plan)?
   }
   ```
   


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

Reply via email to