a-agmon commented on issue #246:
URL: https://github.com/apache/iceberg-rust/issues/246#issuecomment-1991011883

   Hi @liurenjie1024 , 
   Thanks for adding this in response to my question on Slack :-) 
   I would be happy to work on this as good-first-issue if you think its a good 
idea.
   I have implemented something similar for our use case. I can try and PR if 
you think any of the options here are in the right direction. 
   This might be something modest on table.rs such as: 
   
   ```rust
       pub fn from_metadata(
           metadata: TableMetadata,
           table_ident: TableIdent,
           file_io: FileIO,
       ) -> Self {
           Self::builder()
               .metadata(metadata)
               .identifier(table_ident)
               .file_io(file_io)
               .build()
       }
   ```
   
   or more ergonomic like the Python version - something like this (that's the 
way I have implemented this): 
   ```rust
   async fn from_metadata(metadata_file_location: &str, file_io: FileIO) -> 
anyhow::Result<Table> {
       let metadata_file = file_io.new_input(metadata_file_location)?;
       let mut metadata_file_reader = metadata_file.reader().await?;
       let mut metadata_file_content = String::new();
       metadata_file_reader
           .read_to_string(&mut metadata_file_content)
           .await?;
       let table_metadata = 
serde_json::from_str::<TableMetadata>(&metadata_file_content)?;
       Ok(Table::builder()
           .metadata(table_metadata)
           .identifier(TableIdent::from_strs(["static_ns", 
"static_table"]).unwrap())
           .file_io(file_io)
           .build())
   }
   ```
   either way would be happy to hear what you think
   


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