timsaucer opened a new pull request, #25749:
URL: https://github.com/apache/datafusion/pull/25749

   ## Which issue does this PR close?
   
   - Closes #25717.
   
   ## Rationale for this change
   
   A transparent wrapper `ExecutionPlan` (one that implements 
`downcast_delegate`, such as `datafusion-tracing`'s `InstrumentedExec`) around 
a `ForeignExecutionPlan` is silently dropped when it is passed back across the 
FFI boundary. For example, installing the tracing instrumentation rule via FFI 
leaves the plan un-instrumented. Also, when such a wrapper is the child of a 
foreign plan, it does not receive the runtime handle.
   
   ## What changes are included in this PR?
   
   - `FFI_ExecutionPlan::new`: the "already foreign" shortcut now checks the 
concrete type via `Any` instead of the delegate-aware `downcast_ref`, so it 
only fires for a real `ForeignExecutionPlan`.
   - `pass_runtime_to_children`: the child check also uses `Any`, so a local 
wrapper child of a foreign parent is re-wrapped with the runtime.
   - `plan_is_foreign` intentionally stays delegate-aware, since a delegating 
wrapper typically forwards `replace_children` to the foreign plan and its 
children still need the runtime. A comment explains this.
   
   ## What is the testing strategy for this PR?
   
   - Added an optional `downcast_delegate` mode to the existing `EmptyExec` 
test plan (`with_downcast_delegate`).
   - Added `test_ffi_execution_plan_delegating_wrapper`, which checks that the 
wrapper survives `FFI_ExecutionPlan::new` and that a wrapper child of a foreign 
parent gets the runtime. Reverting either fix on its own makes the test fail.
   
   ## Are there any user-facing changes?
   
   No API changes. Wrapper plans that implement `downcast_delegate` are now 
kept when they cross the FFI boundary instead of being discarded.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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