timsaucer commented on code in PR #24723:
URL: https://github.com/apache/datafusion/pull/24723#discussion_r3872084108
##########
datafusion/ffi/src/proto/logical_extension_codec.rs:
##########
@@ -302,7 +311,9 @@ impl FFI_LogicalExtensionCodec {
if let Some(codec) = (Arc::clone(&codec) as Arc<dyn Any>)
.downcast_ref::<ForeignLogicalExtensionCodec>()
{
- return codec.0.clone();
+ let mut codec = codec.0.clone();
+ codec.task_ctx_provider = task_ctx_provider.into();
+ return codec;
Review Comment:
This is the core of the PR.
##########
datafusion/ffi/src/proto/physical_extension_codec.rs:
##########
@@ -288,7 +297,9 @@ impl FFI_PhysicalExtensionCodec {
if let Some(codec) = (Arc::clone(&codec) as Arc<dyn Any>)
.downcast_ref::<ForeignPhysicalExtensionCodec>()
{
- return codec.0.clone();
+ let mut codec = codec.0.clone();
+ codec.task_ctx_provider = task_ctx_provider.into();
+ return codec;
Review Comment:
This is the core of the PR.
##########
datafusion/ffi/src/table_provider.rs:
##########
@@ -564,14 +564,26 @@ impl FFI_TableProvider {
)
}
+ /// Creates an [`FFI_TableProvider`] using a prebuilt FFI logical codec.
+ ///
+ /// If `provider` is already foreign, this re-exports its original FFI
+ /// handle rather than adding another wrapper layer. The handle still
adopts
+ /// the `logical_codec` supplied here, so it is never silently discarded
and
+ /// an imported provider can be rebound to a different session.
+ ///
+ /// `runtime` is only honored when a new wrapper is created. An
+ /// already-foreign handle keeps the runtime of the library that owns it,
+ /// because that value lives in private data this side cannot reach.
pub fn new_with_ffi_codec(
provider: Arc<dyn TableProvider>,
can_support_pushdown_filters: bool,
runtime: Option<Handle>,
logical_codec: FFI_LogicalExtensionCodec,
) -> Self {
if let Some(provider) =
provider.downcast_ref::<ForeignTableProvider>() {
- return provider.0.clone();
+ let mut provider = provider.0.clone();
+ provider.logical_codec = logical_codec;
+ return provider;
Review Comment:
This is the core of the PR.
--
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]