MCPcopy Create free account
hub / github.com/apache/datafusion / test_table_provider

Function test_table_provider

datafusion/ffi/tests/ffi_integration.rs:39–62  ·  view source on GitHub ↗

It is important that this test is in the `tests` directory and not in the library directory so we can verify we are building a dynamic library and testing it via a different executable.

(synchronous: bool)

Source from the content-addressed store, hash-verified

37 /// library directory so we can verify we are building a dynamic library and
38 /// testing it via a different executable.
39 async fn test_table_provider(synchronous: bool) -> Result<()> {
40 let table_provider_module = get_module()?;
41 let (ctx, codec) = super::utils::ctx_and_codec();
42
43 // By calling the code below, the table provided will be created within
44 // the module's code.
45 let ffi_table_provider = (table_provider_module.create_table)(synchronous, codec);
46
47 // In order to access the table provider within this executable, we need to
48 // turn it into a `TableProvider`.
49 let foreign_table_provider: Arc<dyn TableProvider> = (&ffi_table_provider).into();
50
51 // Display the data to show the full cycle works.
52 ctx.register_table("external_table", foreign_table_provider)?;
53 let df = ctx.table("external_table").await?;
54 let results = df.collect().await?;
55
56 assert_eq!(results.len(), 3);
57 assert!(results.contains(&create_record_batch(1, 5)));
58 assert!(results.contains(&create_record_batch(6, 1)));
59 assert!(results.contains(&create_record_batch(7, 5)));
60
61 Ok(())
62 }
63
64 #[tokio::test]
65 async fn async_test_table_provider() -> Result<()> {

Callers 2

sync_test_table_providerFunction · 0.85

Calls 6

get_moduleFunction · 0.85
ctx_and_codecFunction · 0.85
collectMethod · 0.80
intoMethod · 0.45
register_tableMethod · 0.45
tableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…