Skip to content

Commit

Permalink
Replace UnboundPartitionSpec Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
c-thiel committed Jul 27, 2024
1 parent e3272c8 commit a8b844b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions crates/catalog/rest/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions crates/iceberg/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,22 +802,24 @@ mod tests {
.transform(Transform::Day)
.build(),
)
.unwrap()
.with_unbound_partition_field(
UnboundPartitionField::builder()
.source_id(1)
.name("id_bucket".to_string())
.transform(Transform::Bucket(16))
.build(),
)
.unwrap()
.with_unbound_partition_field(
UnboundPartitionField::builder()
.source_id(2)
.name("id_truncate".to_string())
.transform(Transform::Truncate(4))
.build(),
)
.build()
.unwrap(),
.unwrap()
.build_unbound(),
},
);
}
Expand Down
9 changes: 3 additions & 6 deletions crates/iceberg/src/spec/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32>,
/// Details of the partition spec
#[builder(setter(each(name = "with_unbound_partition_field")))]
pub fields: Vec<UnboundPartitionField>,
}

impl UnboundPartitionSpec {
/// Create unbound partition spec builer
pub fn builder() -> UnboundPartitionSpecBuilder {
UnboundPartitionSpecBuilder::default()
pub fn builder() -> PartitionSpecBuilder {
PartitionSpecBuilder::default()
}
}

Expand Down

0 comments on commit a8b844b

Please sign in to comment.