diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index e57152abc0..6a1572a4af 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -261,7 +261,9 @@ pub struct TableCreation { #[builder(default, setter(strip_option(fallback = sort_order_opt)))] pub sort_order: Option, /// The properties of the table. - #[builder(default)] + #[builder(default, setter(transform = |props: impl IntoIterator| { + props.into_iter().collect() + }))] pub properties: HashMap, } @@ -901,6 +903,26 @@ mod tests { assert_eq!(table_id, TableIdent::from_strs(vec!["ns1", "t1"]).unwrap()); } + #[test] + fn test_table_creation_iterator_properties() { + let builder = TableCreation::builder() + .name("table".to_string()) + .schema(Schema::builder().build().unwrap()); + + fn s(k: &str, v: &str) -> (String, String) { + (k.to_string(), v.to_string()) + } + + let table_creation = builder + .properties([s("key", "value"), s("foo", "bar")]) + .build(); + + assert_eq!( + HashMap::from([s("key", "value"), s("foo", "bar")]), + table_creation.properties + ); + } + fn test_serde_json( json: impl ToString, expected: T,