my-vegetable-has-exploded commented on code in PR #106: URL: https://github.com/apache/iceberg-rust/pull/106#discussion_r1410083813
########## crates/iceberg/src/spec/partition.rs: ########## @@ -60,6 +62,99 @@ impl PartitionSpec { } } +static PARTITION_DATA_ID_START: i32 = 1000; + +/// Reference to [`UnboundPartitionSpec`]. +pub type UnboundPartitionSpecRef = Arc<UnboundPartitionSpec>; +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] +#[serde(rename_all = "kebab-case")] +/// Unbound partition field can be built without a schema and later bound to a schema. +pub struct UnboundPartitionField { + /// A source column id from the table’s schema + pub source_id: i32, + /// A partition field id that is used to identify a partition field and is unique within a partition spec. + /// In v2 table metadata, it is unique across all partition specs. + pub partition_id: Option<i32>, + /// A partition name. + pub name: String, + /// A transform that is applied to the source column to produce a partition value. + pub transform: Transform, +} + +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Default, Builder)] +#[serde(rename_all = "kebab-case")] +#[builder(setter(prefix = "with"))] +/// Unbound partition spec can be built without a schema and later bound to a schema. +pub struct UnboundPartitionSpec { + /// Identifier for PartitionSpec + pub spec_id: Option<i32>, + /// Details of the partition spec + #[builder(setter(each(name = "with_unbound_partition_field")))] + pub fields: Vec<UnboundPartitionField>, +} + +impl UnboundPartitionSpec { + /// last assigned id for partitioned field + pub fn unpartitioned_last_assigned_id() -> i32 { + PARTITION_DATA_ID_START - 1 + } + + /// Create unbound partition spec builer + pub fn builder() -> UnboundPartitionSpecBuilder { + UnboundPartitionSpecBuilder::default() + } + + /// Bind unbound partition spec to a schema + pub fn bind(&self, schema: SchemaRef) -> Result<PartitionSpec> { Review Comment: I'm also a little confused about the process. If there's a need, I can try it then. Thanks @liurenjie1024. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org