avantgardnerio commented on code in PR #4095:
URL: https://github.com/apache/arrow-datafusion/pull/4095#discussion_r1013362371
##########
datafusion/core/src/execution/context.rs:
##########
@@ -2145,6 +2195,40 @@ mod tests {
Ok(())
}
+ #[tokio::test]
+ async fn with_listing_schema_provider() -> Result<()> {
+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let url = format!("file://{}/tests/tpch-csv", path.display());
+
+ let mut table_factories: HashMap<String, Arc<dyn
TableProviderFactory>> =
+ HashMap::new();
+ table_factories.insert("test".to_string(), Arc::new(TestTableFactory
{}));
+ let rt_cfg =
RuntimeConfig::new().with_table_factories(table_factories);
+ let runtime = Arc::new(RuntimeEnv::new(rt_cfg).unwrap());
+ let cfg = SessionConfig::new()
+ .set_str("datafusion.catalog.location", url.as_str())
+ .set_str("datafusion.catalog.type", "test");
+ let session_state = SessionState::with_config_rt(cfg, runtime);
+ let ctx = SessionContext::with_state(session_state);
+
+ let mut table_count = 0;
+ for cat_name in ctx.catalog_names().iter() {
+ let cat = ctx.catalog(cat_name).unwrap();
+ for s_name in cat.schema_names().iter() {
+ let schema = cat.schema(s_name).unwrap();
+ if let Some(listing) =
+ schema.as_any().downcast_ref::<ListingSchemaProvider>()
+ {
+ listing.refresh().await.unwrap();
+ }
+ table_count = schema.table_names().len();
+ }
+ }
+
+ assert_eq!(table_count, 8);
Review Comment:
@alamb I think this one test covers all the bases. Let me know if you think
it could/should be improved.
--
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]