From a8b844b39cef1223aca581d394948c4e828cbeb5 Mon Sep 17 00:00:00 2001 From: Christian Thiel Date: Sat, 27 Jul 2024 18:55:00 +0200 Subject: [PATCH] Replace UnboundPartitionSpec Builder --- crates/catalog/rest/src/catalog.rs | 6 +++--- crates/iceberg/src/catalog/mod.rs | 6 ++++-- crates/iceberg/src/spec/partition.rs | 9 +++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/catalog/rest/src/catalog.rs b/crates/catalog/rest/src/catalog.rs index aab615cd6..124adf852 100644 --- a/crates/catalog/rest/src/catalog.rs +++ b/crates/catalog/rest/src/catalog.rs @@ -1467,13 +1467,13 @@ mod tests { .properties(HashMap::from([("owner".to_string(), "testx".to_string())])) .partition_spec( UnboundPartitionSpec::builder() - .with_fields(vec![UnboundPartitionField::builder() + .with_unbound_fields(vec![UnboundPartitionField::builder() .source_id(1) .transform(Transform::Truncate(3)) .name("id".to_string()) .build()]) - .build() - .unwrap(), + .unwrap() + .build_unbound(), ) .sort_order( SortOrder::builder() diff --git a/crates/iceberg/src/catalog/mod.rs b/crates/iceberg/src/catalog/mod.rs index 5c63e1e77..b171ca1b3 100644 --- a/crates/iceberg/src/catalog/mod.rs +++ b/crates/iceberg/src/catalog/mod.rs @@ -802,6 +802,7 @@ mod tests { .transform(Transform::Day) .build(), ) + .unwrap() .with_unbound_partition_field( UnboundPartitionField::builder() .source_id(1) @@ -809,6 +810,7 @@ mod tests { .transform(Transform::Bucket(16)) .build(), ) + .unwrap() .with_unbound_partition_field( UnboundPartitionField::builder() .source_id(2) @@ -816,8 +818,8 @@ mod tests { .transform(Transform::Truncate(4)) .build(), ) - .build() - .unwrap(), + .unwrap() + .build_unbound(), }, ); } diff --git a/crates/iceberg/src/spec/partition.rs b/crates/iceberg/src/spec/partition.rs index 42333e5bc..0e0a680dc 100644 --- a/crates/iceberg/src/spec/partition.rs +++ b/crates/iceberg/src/spec/partition.rs @@ -144,22 +144,19 @@ pub struct UnboundPartitionField { } /// Unbound partition spec can be built without a schema and later bound to a schema. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Default, Builder)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Default)] #[serde(rename_all = "kebab-case")] -#[builder(setter(prefix = "with"))] pub struct UnboundPartitionSpec { /// Identifier for PartitionSpec - #[builder(default, setter(strip_option))] pub spec_id: Option, /// Details of the partition spec - #[builder(setter(each(name = "with_unbound_partition_field")))] pub fields: Vec, } impl UnboundPartitionSpec { /// Create unbound partition spec builer - pub fn builder() -> UnboundPartitionSpecBuilder { - UnboundPartitionSpecBuilder::default() + pub fn builder() -> PartitionSpecBuilder { + PartitionSpecBuilder::default() } }