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)
| 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<()> { |
no test coverage detected
searching dependent graphs…