alamb commented on issue #17510:
URL: https://github.com/apache/datafusion/issues/17510#issuecomment-3281776242

   when I add this code to the  original reproducer the test now passes. 
   
   ```rust
       let optimized_plan = optimized_plan.reset_state().unwrap();
   ```
   
   Using @adriangb 's reproducer, when I uncommented out the line
   
   ```rust
       // let plan_2 = plan_2.reset_state().unwrap();
   ```
   
   The test passes for me on DataFusion 49 and when I comment it back out then 
the test fails
   
   
   Thus, I think the solution is to call `reset_state`. 
   
   The root cause seems to be that code doesn't really copy the plan so this 
example is running the same plan twice.
   
   This line specifically:
   ```rust
       let optimized_plan = optimizer.optimize(plan.clone(), 
&Default::default())?;
   ```
   
   `plan` is an `Arc<dyn ExecutionPlan>` so calling `clone` on it just copies 
the pointer
   
   
   Similarly, in @adriangb 's version `plan_1` is an `Arc<dyn ExecutionPlan>` 
so calling `clone` on it just copies the pointer
   
   ```rust
       let plan_1 = 
ctx.state().create_physical_plan(&logical_plan).await.unwrap();
       let plan_2 = plan_1.clone();
   ```
   
   So in effect what the reproducers are doing is calling `execute()` on the 
same plan twice. Thus I would expect that calling `reset_state` on the plan 
would be needed to reset any internal state, which is exactly the behavior we 
see
   
   


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

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