Skip to content

Commit

Permalink
Add version call on FFI integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
timsaucer committed Dec 29, 2024
1 parent a9901a8 commit ca12635
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datafusion/ffitest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ mod sync_provider;
pub struct TableProviderModule {
/// Constructs the table provider
pub create_table: extern "C" fn(synchronous: bool) -> FFI_TableProvider,

pub version: extern "C" fn() -> u64,
}

impl RootModule for TableProviderModuleRef {
Expand Down Expand Up @@ -91,6 +93,7 @@ extern "C" fn construct_table_provider(synchronous: bool) -> FFI_TableProvider {
pub fn get_simple_memory_table() -> TableProviderModuleRef {
TableProviderModule {
create_table: construct_table_provider,
version: datafusion_ffi::version,
}
.leak_into_prefix()
}
9 changes: 9 additions & 0 deletions datafusion/ffitest/tests/table_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use std::sync::Arc;
/// library directory so we can verify we are building a dynamic library and
/// testing it via a different executable.
async fn test_table_provider(synchronous: bool) -> Result<()> {
let expected_version = datafusion_ffi::version();

let crate_root = Path::new(env!("CARGO_MANIFEST_DIR"));
let target_dir = crate_root
.parent()
Expand All @@ -32,6 +34,13 @@ async fn test_table_provider(synchronous: bool) -> Result<()> {
TableProviderModuleRef::load_from_directory(&library_path)
.map_err(|e| DataFusionError::External(Box::new(e)))?;

assert_eq!(
table_provider_module
.version()
.expect("Unable to call version on FFI module")(),
expected_version
);

// By calling the code below, the table provided will be created within
// the module's code.
let ffi_table_provider =
Expand Down

0 comments on commit ca12635

Please sign in to comment.