c-thiel opened a new pull request, #1362:
URL: https://github.com/apache/iceberg-rust/pull/1362

   ## Which issue does this PR close?
   
   Currently we don't have a way to create `TableMetadata` in a declarative way 
other than deserializing it from JSON.
   The `TableMetadataBuilder` mostly works imperatively with methods like 
`add_schema` and `add_partition_spec` that mutate the state incrementally. 
While incremental modification is what most users need, it is also helpful to 
offer a type safe way to create a new `TableMetadata` object given all of its 
attributes, other than deserialization from JSON.
   
   My concrete use-case is: Lakekeeper stores TableMetadata in Postgres. We 
extract data typesafe, so we end up with various objects such as a list of 
schemas, partition_specs, the last_updated_ms and all other fields required to 
build a new `TableMetadata`. As we already have rust-types, we don't want to 
serialize them to JSON first. We also can't use the `TableMetadata` builder, as 
it's incremental nature would result in significant overhead.
   
   ## Desin considerations
   Instead of using the builder approach, we could also just add another method 
`try_from_parts` or similar to `impl TableMetadata`. We have this alternative 
approach implemented here: 
https://github.com/lakekeeper/iceberg-rust/blob/a8b6509775b139c92772a999b0cbca637e274a03/crates/iceberg/src/spec/table_metadata.rs#L676-L740
   
   I feel that a builder is less intrusive though. I don't like adding the 
`UnnormalizedTableMetadata`, but didn't find a way to skip this type without 
writing significantly more code that needs maintenance. Because we have the 
derived builder here now, this approach is almost maintenance free.
   
   ## What changes are included in this PR?
   
   * Introduce a new derived `TableMetadataDeclarativeBuilder`
   * Introduce `UnnormalizedTableMetadata` as an intermediate type that is 
`.try_normalize()` to `TableMetadata`
   
   ## Are these changes tested?
   
   yes


-- 
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

Reply via email to