From c19d2e087dacbf4e5055e79c27624de65c56ca86 Mon Sep 17 00:00:00 2001 From: Tim Saucer Date: Tue, 7 Apr 2026 16:18:01 -0400 Subject: [PATCH] [BRANCH-52] fix: foreign inner ffi types (#21439) ## Which issue does this PR close? - Closes #21155 ## Rationale for this change This fixes a regression on using foreign schema + catalog + table providers. ## What changes are included in this PR? Check for existing Foreign types, and get their inner FFI type if available. ## Are these changes tested? Tested internally at rerun in production. Also code is backported from df-53 ## Are there any user-facing changes? None --- datafusion/ffi/src/catalog_provider.rs | 5 +++++ datafusion/ffi/src/schema_provider.rs | 5 +++++ datafusion/ffi/src/table_provider.rs | 3 +++ 3 files changed, 13 insertions(+) diff --git a/datafusion/ffi/src/catalog_provider.rs b/datafusion/ffi/src/catalog_provider.rs index 61e26f166353..ff588a89a71b 100644 --- a/datafusion/ffi/src/catalog_provider.rs +++ b/datafusion/ffi/src/catalog_provider.rs @@ -250,6 +250,11 @@ impl FFI_CatalogProvider { runtime: Option, logical_codec: FFI_LogicalExtensionCodec, ) -> Self { + if let Some(provider) = provider.as_any().downcast_ref::() + { + return provider.0.clone(); + } + let private_data = Box::new(ProviderPrivateData { provider, runtime }); Self { diff --git a/datafusion/ffi/src/schema_provider.rs b/datafusion/ffi/src/schema_provider.rs index b8e44b134f87..5d1348e2328f 100644 --- a/datafusion/ffi/src/schema_provider.rs +++ b/datafusion/ffi/src/schema_provider.rs @@ -259,6 +259,11 @@ impl FFI_SchemaProvider { runtime: Option, logical_codec: FFI_LogicalExtensionCodec, ) -> Self { + if let Some(provider) = provider.as_any().downcast_ref::() + { + return provider.0.clone(); + } + let owner_name = provider.owner_name().map(|s| s.into()).into(); let private_data = Box::new(ProviderPrivateData { provider, runtime }); diff --git a/datafusion/ffi/src/table_provider.rs b/datafusion/ffi/src/table_provider.rs index 1559549e6362..4a89bb025a56 100644 --- a/datafusion/ffi/src/table_provider.rs +++ b/datafusion/ffi/src/table_provider.rs @@ -391,6 +391,9 @@ impl FFI_TableProvider { runtime: Option, logical_codec: FFI_LogicalExtensionCodec, ) -> Self { + if let Some(provider) = provider.as_any().downcast_ref::() { + return provider.0.clone(); + } let private_data = Box::new(ProviderPrivateData { provider, runtime }); Self {