davisp commented on code in PR #20326:
URL: https://github.com/apache/datafusion/pull/20326#discussion_r2835172340


##########
datafusion/ffi/src/table_provider_factory.rs:
##########
@@ -0,0 +1,492 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::{ffi::c_void, sync::Arc};
+
+use abi_stable::{
+    StableAbi,
+    std_types::{RResult, RString, RVec},
+};
+use async_ffi::{FfiFuture, FutureExt};
+use async_trait::async_trait;
+use datafusion_catalog::{Session, TableProvider, TableProviderFactory};
+use datafusion_common::TableReference;
+use datafusion_common::error::{DataFusionError, Result};
+use datafusion_execution::TaskContext;
+use datafusion_expr::CreateExternalTable;
+use datafusion_proto::logical_plan::from_proto::{parse_expr, parse_sorts};
+use datafusion_proto::logical_plan::to_proto::{serialize_expr, 
serialize_sorts};
+use datafusion_proto::logical_plan::{
+    DefaultLogicalExtensionCodec, LogicalExtensionCodec,
+};
+use datafusion_proto::protobuf::{CreateExternalTableNode, 
SortExprNodeCollection};
+use prost::Message;
+use std::collections::HashMap;
+use tokio::runtime::Handle;
+
+use crate::execution::FFI_TaskContextProvider;
+use crate::proto::logical_extension_codec::FFI_LogicalExtensionCodec;
+use crate::session::{FFI_SessionRef, ForeignSession};
+use crate::table_provider::{FFI_TableProvider, ForeignTableProvider};
+use crate::{df_result, rresult_return};
+
+/// A stable struct for sharing [`TableProviderFactory`] across FFI boundaries.
+///
+/// Similar to [`FFI_TableProvider`], this struct uses the FFI-safe pattern 
where:
+/// - The `FFI_*` struct exposes stable function pointers
+/// - Private data is stored as an opaque pointer
+/// - The `Foreign*` wrapper is used by consumers on the other side of the FFI 
boundary
+///
+/// [`FFI_TableProvider`]: crate::table_provider::FFI_TableProvider
+#[repr(C)]
+#[derive(Debug, StableAbi)]
+pub struct FFI_TableProviderFactory {
+    /// Create a TableProvider with the given command.
+    ///
+    /// # Arguments
+    ///
+    /// * `factory` - the table provider factory
+    /// * `session_config` - session configuration
+    /// * `cmd_serialized` - a [`CreateExternalTableNode`] protobuf message 
serialized into bytes
+    ///   to pass across the FFI boundary.
+    create: unsafe extern "C" fn(
+        factory: &Self,
+        session: FFI_SessionRef,
+        cmd_serialized: RVec<u8>,
+    ) -> FfiFuture<RResult<FFI_TableProvider, RString>>,
+
+    pub logical_codec: FFI_LogicalExtensionCodec,
+
+    /// Used to create a clone of the factory. This should only need to be 
called
+    /// by the receiver of the factory.
+    pub clone: unsafe extern "C" fn(factory: &Self) -> Self,

Review Comment:
   Fixed 
[here](https://github.com/apache/datafusion/pull/20326/changes/8ca3a0fd63d59c08f7e80b4d56ccea40ee7a2bf4).



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