liurenjie1024 opened a new issue, #232:
URL: https://github.com/apache/iceberg-rust/issues/232

   # Problem statement
   
   `TableMetadataBuilder` is useful in modifying/creating `TableMetadata`, and 
is a core data structure of transaction api. There are already some efforts to 
create one using derived builder, see 
https://github.com/apache/iceberg-rust/pull/62 and 
https://github.com/apache/iceberg-rust/pull/229. While it's easy to implement, 
I have some concerns about this approach. There are some problems with this 
approach:
   
   1. Not easy to review. it's quite easy to forget that we have changed 
builder api when we do modification to `TableMetadata`.
   2. Not easy to customize. I've checked the builder in [java 
api](https://github.com/apache/iceberg/blob/2e291c2b67a643ffe93e139483df55f3639cc39d/core/src/main/java/org/apache/iceberg/TableMetadata.java#L857),
 and it has a lot of customization in each method with validations.
   
   The reason I want to be careful with `TableMetadataBuilder` is that it's a 
core data structure in iceberg, and we should not expose apis which be misused 
to construct inconsistent `TableMetadata`.
   
   # Proposal
   
   I want to propose to implement `TableMetadataBuilder` in a similar approach 
like [java 
api](https://github.com/apache/iceberg/blob/2e291c2b67a643ffe93e139483df55f3639cc39d/core/src/main/java/org/apache/iceberg/TableMetadata.java#L857),
 rather than using derived builder directly, such as following:
   ```rust
   pub struct TableMetadataBuilder(TableMetadata);
   
   impl TableMetadataBuilder {
      pub fn add_schema(mut self, schema: Schema) -> Result<Self> {
          // Check if schema validity
      }
   
     pub fn add_unbound_partition_spec(mut self, spec: UnboundPartitionSpec) -> 
Result<Self> { 
      // Binding partition spec
     }
   
     pub fn build(self) -> Result<TableMetadata> {}
   }
   ```
   
   
   


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