From 250f093286beadfc505bd432f4998ed996d0201d Mon Sep 17 00:00:00 2001 From: shekharrajak Date: Sat, 7 Feb 2026 11:05:05 +0530 Subject: [PATCH 1/2] feat(playground): add memory catalog support --- crates/integrations/playground/src/catalog.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/integrations/playground/src/catalog.rs b/crates/integrations/playground/src/catalog.rs index f7fd14ca84..e1c1b8d0f6 100644 --- a/crates/integrations/playground/src/catalog.rs +++ b/crates/integrations/playground/src/catalog.rs @@ -23,6 +23,7 @@ use std::sync::Arc; use anyhow::anyhow; use datafusion::catalog::{CatalogProvider, CatalogProviderList}; use fs_err::read_to_string; +use iceberg::memory::MemoryCatalogBuilder; use iceberg::CatalogBuilder; use iceberg_catalog_rest::RestCatalogBuilder; use iceberg_datafusion::IcebergCatalogProvider; @@ -78,10 +79,6 @@ impl IcebergCatalogList { .as_str() .ok_or_else(|| anyhow::anyhow!("type is not string"))?; - if r#type != "rest" { - return Err(anyhow::anyhow!("Only rest catalog is supported for now!")); - } - let catalog_config = config .get("config") .ok_or_else(|| anyhow::anyhow!("config not found for catalog {name}"))? @@ -96,11 +93,21 @@ impl IcebergCatalogList { .ok_or_else(|| anyhow::anyhow!("props {key} is not string"))?; props.insert(key.to_string(), value_str.to_string()); } - let catalog = RestCatalogBuilder::default().load(name, props).await?; + + // Create catalog based on type using the appropriate builder + let catalog: Arc = match r#type { + "rest" => Arc::new(RestCatalogBuilder::default().load(name, props).await?), + "memory" => Arc::new(MemoryCatalogBuilder::default().load(name, props).await?), + _ => { + return Err(anyhow::anyhow!( + "Unsupported catalog type: '{type}'. Supported types: rest, memory" + )) + } + }; Ok(( name.to_string(), - Arc::new(IcebergCatalogProvider::try_new(Arc::new(catalog)).await?), + Arc::new(IcebergCatalogProvider::try_new(catalog).await?), )) } } From 583aafc8705891a426760fd6ed1264e446f80422 Mon Sep 17 00:00:00 2001 From: shekharrajak Date: Sat, 7 Feb 2026 11:11:04 +0530 Subject: [PATCH 2/2] test(playground): add unit tests for memory catalog support --- crates/integrations/playground/src/catalog.rs | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/crates/integrations/playground/src/catalog.rs b/crates/integrations/playground/src/catalog.rs index e1c1b8d0f6..66742ab893 100644 --- a/crates/integrations/playground/src/catalog.rs +++ b/crates/integrations/playground/src/catalog.rs @@ -23,8 +23,8 @@ use std::sync::Arc; use anyhow::anyhow; use datafusion::catalog::{CatalogProvider, CatalogProviderList}; use fs_err::read_to_string; -use iceberg::memory::MemoryCatalogBuilder; use iceberg::CatalogBuilder; +use iceberg::memory::MemoryCatalogBuilder; use iceberg_catalog_rest::RestCatalogBuilder; use iceberg_datafusion::IcebergCatalogProvider; use toml::{Table as TomlTable, Value}; @@ -101,7 +101,7 @@ impl IcebergCatalogList { _ => { return Err(anyhow::anyhow!( "Unsupported catalog type: '{type}'. Supported types: rest, memory" - )) + )); } }; @@ -136,3 +136,74 @@ impl CatalogProviderList for IcebergCatalogList { .map(|c| c.clone() as Arc) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_parse_memory_catalog() { + let config = r#" + [[catalogs]] + name = "test_memory" + type = "memory" + [catalogs.config] + warehouse = "/tmp/test-warehouse" + "#; + + let toml_table: TomlTable = toml::from_str(config).unwrap(); + let catalog_list = IcebergCatalogList::parse_table(&toml_table).await.unwrap(); + + assert!( + catalog_list + .catalog_names() + .contains(&"test_memory".to_string()) + ); + assert!(catalog_list.catalog("test_memory").is_some()); + } + + #[tokio::test] + async fn test_parse_unsupported_catalog_type() { + let config = r#" + [[catalogs]] + name = "test_hive" + type = "hive" + [catalogs.config] + uri = "thrift://localhost:9083" + "#; + + let toml_table: TomlTable = toml::from_str(config).unwrap(); + let result = IcebergCatalogList::parse_table(&toml_table).await; + + assert!(result.is_err()); + let err_msg = result.unwrap_err().to_string(); + assert!(err_msg.contains("Unsupported catalog type")); + assert!(err_msg.contains("hive")); + assert!(err_msg.contains("rest, memory")); + } + + #[tokio::test] + async fn test_catalog_names() { + let config = r#" + [[catalogs]] + name = "catalog_one" + type = "memory" + [catalogs.config] + warehouse = "/tmp/warehouse1" + + [[catalogs]] + name = "catalog_two" + type = "memory" + [catalogs.config] + warehouse = "/tmp/warehouse2" + "#; + + let toml_table: TomlTable = toml::from_str(config).unwrap(); + let catalog_list = IcebergCatalogList::parse_table(&toml_table).await.unwrap(); + + let names = catalog_list.catalog_names(); + assert_eq!(names.len(), 2); + assert!(names.contains(&"catalog_one".to_string())); + assert!(names.contains(&"catalog_two".to_string())); + } +}