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

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #19277 
   - Addresses part of #18671 
   - Follow-up to #19223 
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   One of the reasons we are unable to fully utilize the native session context 
across the FFI boundary is that the `Session` trait implementation for FFI 
(`ForeignSession`) was missing implementations for `runtime_env` and 
`execution_props`.
   
   Currently, table providers using FFI often have to rebuild a temporary 
session or rely on default values, which means they lose access to critical 
context like the memory pool or query start time.
   
   By implementing `runtime_env` and `execution_props` in `FFI_SessionRef` and 
`ForeignSession`, we enable downstream users (such as foreign table providers) 
to access the actual runtime environment and execution properties of the host 
session.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Defined `FFI_ExecutionProps` and `FFI_RuntimeEnv` structs to safely wrap 
`ExecutionProps` and `Arc<RuntimeEnv>` across the FFI boundary.
   - Updated `FFI_SessionRef` to include function pointers for `runtime_env` 
and `execution_props`.
   - Updated `ForeignSession::try_from` to correctly extract and hold these 
values from the FFI provider.
   - Implemented proper memory management (`Drop` / `release`) to prevent 
double-free errors when ownership is transferred.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   Yes. The existing `test_ffi_session` in `datafusion/ffi/src/session/mod.rs` 
has been extended to verify that:
   1. The `RuntimeEnv` accessible via the foreign session is the same instance 
(pointer equality) as the host session.
   2. The `ExecutionProps` (specifically `query_execution_start_time`) are 
correctly carried over.
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   
   Yes, the `FFI_Session` API has been extended. This is a breaking change for 
any external implementers of the raw FFI protocol (as the struct layout has 
changed), though it is backward compatible for users of the high-level Rust 
wrappers.


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