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

Function test_async_schema_provider_resolve

datafusion/catalog/src/async.rs:488–553  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

486
487 #[tokio::test]
488 async fn test_async_schema_provider_resolve() {
489 async fn check(
490 refs: Vec<TableReference>,
491 expected_lookup_count: u32,
492 found_tables: &[&str],
493 not_found_tables: &[&str],
494 ) {
495 let async_provider = MockAsyncSchemaProvider::default();
496 let cached_provider = async_provider
497 .resolve(&refs, &test_config(), MOCK_CATALOG, MOCK_SCHEMA)
498 .await
499 .unwrap();
500
501 assert_eq!(
502 async_provider.lookup_count.load(Ordering::Acquire),
503 expected_lookup_count
504 );
505
506 for table_ref in found_tables {
507 let table = cached_provider.table(table_ref).await.unwrap();
508 assert!(table.is_some());
509 }
510
511 for table_ref in not_found_tables {
512 assert!(cached_provider.table(table_ref).await.unwrap().is_none());
513 }
514 }
515
516 // Basic full lookups
517 check(
518 vec![
519 TableReference::full(MOCK_CATALOG, MOCK_SCHEMA, MOCK_TABLE),
520 TableReference::full(MOCK_CATALOG, MOCK_SCHEMA, "not_exists"),
521 ],
522 2,
523 &[MOCK_TABLE],
524 &["not_exists"],
525 )
526 .await;
527
528 // Catalog / schema mismatch doesn't even search
529 check(
530 vec![
531 TableReference::full(MOCK_CATALOG, "foo", MOCK_TABLE),
532 TableReference::full("foo", MOCK_SCHEMA, MOCK_TABLE),
533 ],
534 0,
535 &[],
536 &[MOCK_TABLE],
537 )
538 .await;
539
540 // Both hits and misses cached
541 check(
542 vec![
543 TableReference::full(MOCK_CATALOG, MOCK_SCHEMA, MOCK_TABLE),
544 TableReference::full(MOCK_CATALOG, MOCK_SCHEMA, MOCK_TABLE),
545 TableReference::full(MOCK_CATALOG, MOCK_SCHEMA, "not_exists"),

Callers

nothing calls this directly

Calls 1

checkFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…