Skip to content
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ iceberg-catalog-rest = { version = "0.7.0", path = "./crates/catalog/rest" }
iceberg-catalog-glue = { version = "0.7.0", path = "./crates/catalog/glue" }
iceberg-catalog-s3tables = { version = "0.7.0", path = "./crates/catalog/s3tables" }
iceberg-catalog-hms = { version = "0.7.0", path = "./crates/catalog/hms" }
iceberg-catalog-sql = { version = "0.7.0", path = "./crates/catalog/sql" }
iceberg-datafusion = { version = "0.7.0", path = "./crates/integrations/datafusion" }
indicatif = "0.17"
itertools = "0.13"
Expand Down
9 changes: 9 additions & 0 deletions crates/catalog/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@ iceberg-catalog-rest = { workspace = true }
iceberg-catalog-glue = { workspace = true }
iceberg-catalog-s3tables = { workspace = true }
iceberg-catalog-hms = { workspace = true }
iceberg-catalog-sql = { workspace = true }
tokio = { workspace = true }
async-trait = { workspace = true }

[dev-dependencies]
sqlx = { version = "0.8.1", features = [
"runtime-tokio",
"sqlite",
"migrate",
], default-features = false }
tempfile = { workspace = true }
34 changes: 34 additions & 0 deletions crates/catalog/loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use iceberg_catalog_glue::GlueCatalogBuilder;
use iceberg_catalog_hms::HmsCatalogBuilder;
use iceberg_catalog_rest::RestCatalogBuilder;
use iceberg_catalog_s3tables::S3TablesCatalogBuilder;
use iceberg_catalog_sql::SqlCatalogBuilder;

/// A CatalogBuilderFactory creating a new catalog builder.
type CatalogBuilderFactory = fn() -> Box<dyn BoxedCatalogBuilder>;
Expand All @@ -34,6 +35,7 @@ static CATALOG_REGISTRY: &[(&str, CatalogBuilderFactory)] = &[
("glue", || Box::new(GlueCatalogBuilder::default())),
("s3tables", || Box::new(S3TablesCatalogBuilder::default())),
("hms", || Box::new(HmsCatalogBuilder::default())),
("sql", || Box::new(SqlCatalogBuilder::default())),
];

/// Return the list of supported catalog types.
Expand Down Expand Up @@ -108,6 +110,9 @@ impl CatalogLoader<'_> {
mod tests {
use std::collections::HashMap;

use sqlx::migrate::MigrateDatabase;
use tempfile::TempDir;

use crate::{CatalogLoader, load};

#[tokio::test]
Expand Down Expand Up @@ -220,6 +225,35 @@ mod tests {
assert!(catalog.is_ok());
}

fn temp_path() -> String {
let temp_dir = TempDir::new().unwrap();
temp_dir.path().to_str().unwrap().to_string()
}

#[tokio::test]
async fn test_catalog_loader_pattern_sql_catalog() {
use iceberg_catalog_sql::{SQL_CATALOG_PROP_URI, SQL_CATALOG_PROP_WAREHOUSE};

let uri = format!("sqlite:{}", temp_path());
sqlx::Sqlite::create_database(&uri).await.unwrap();

let catalog_loader = load("sql").unwrap();
let catalog = catalog_loader
.load(
"sql".to_string(),
HashMap::from([
(SQL_CATALOG_PROP_URI.to_string(), uri),
(
SQL_CATALOG_PROP_WAREHOUSE.to_string(),
"s3://warehouse".to_string(),
),
]),
)
.await;

assert!(catalog.is_ok());
}

#[tokio::test]
async fn test_error_message_includes_supported_types() {
let err = match load("does-not-exist") {
Expand Down
3 changes: 1 addition & 2 deletions crates/catalog/sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ repository = { workspace = true }
async-trait = { workspace = true }
iceberg = { workspace = true }
sqlx = { version = "0.8.1", features = ["any"], default-features = false }
typed-builder = { workspace = true }
strum = { workspace = true }

[dev-dependencies]
iceberg_test_utils = { path = "../../test_utils", features = ["tests"] }
itertools = { workspace = true }
regex = "1.10.5"
sqlx = { version = "0.8.1", features = [
Expand Down
Loading
Loading