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

Function cross_catalog_access

datafusion/core/src/execution/context/mod.rs:2657–2697  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2655
2656 #[tokio::test]
2657 async fn cross_catalog_access() -> Result<()> {
2658 let ctx = SessionContext::new();
2659
2660 let catalog_a = MemoryCatalogProvider::new();
2661 let schema_a = MemorySchemaProvider::new();
2662 schema_a
2663 .register_table("table_a".to_owned(), test::table_with_sequence(1, 1)?)?;
2664 catalog_a.register_schema("schema_a", Arc::new(schema_a))?;
2665 ctx.register_catalog("catalog_a", Arc::new(catalog_a));
2666
2667 let catalog_b = MemoryCatalogProvider::new();
2668 let schema_b = MemorySchemaProvider::new();
2669 schema_b
2670 .register_table("table_b".to_owned(), test::table_with_sequence(1, 2)?)?;
2671 catalog_b.register_schema("schema_b", Arc::new(schema_b))?;
2672 ctx.register_catalog("catalog_b", Arc::new(catalog_b));
2673
2674 let result = plan_and_collect(
2675 &ctx,
2676 "SELECT cat, SUM(i) AS total FROM (
2677 SELECT i, 'a' AS cat FROM catalog_a.schema_a.table_a
2678 UNION ALL
2679 SELECT i, 'b' AS cat FROM catalog_b.schema_b.table_b
2680 ) AS all
2681 GROUP BY cat
2682 ORDER BY cat
2683 ",
2684 )
2685 .await?;
2686
2687 assert_snapshot!(batches_to_string(&result), @r"
2688 +-----+-------+
2689 | cat | total |
2690 +-----+-------+
2691 | a | 1 |
2692 | b | 3 |
2693 +-----+-------+
2694 ");
2695
2696 Ok(())
2697 }
2698
2699 #[tokio::test]
2700 async fn catalogs_not_leaked() {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
table_with_sequenceFunction · 0.85
plan_and_collectFunction · 0.50
register_tableMethod · 0.45
register_schemaMethod · 0.45
register_catalogMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…