CTTY commented on code in PR #1451:
URL: https://github.com/apache/iceberg-rust/pull/1451#discussion_r2159720577


##########
crates/iceberg/src/transaction/mod.rs:
##########
@@ -45,60 +45,55 @@ use crate::{Catalog, TableCommit, TableRequirement, 
TableUpdate};
 
 /// Table transaction.
 pub struct Transaction {
-    base_table: Table,
-    current_table: Table,
+    table: Table,
     actions: Vec<BoxedTransactionAction>,
-    updates: Vec<TableUpdate>,
-    requirements: Vec<TableRequirement>,
 }
 
 impl Transaction {
     /// Creates a new transaction.
     pub fn new(table: &Table) -> Self {
         Self {
-            base_table: table.clone(),
-            current_table: table.clone(),
+            table: table.clone(),
             actions: vec![],
-            updates: vec![],
-            requirements: vec![],
         }
     }
 
-    fn update_table_metadata(&mut self, updates: &[TableUpdate]) -> Result<()> 
{
-        let mut metadata_builder = 
self.current_table.metadata().clone().into_builder(None);
+    fn update_table_metadata(&self, table: &mut Table, updates: 
&[TableUpdate]) -> Result<()> {
+        let mut metadata_builder = table.metadata().clone().into_builder(None);
         for update in updates {
             metadata_builder = update.clone().apply(metadata_builder)?;
         }
 
-        self.current_table
-            .with_metadata(Arc::new(metadata_builder.build()?.metadata));
+        table.with_metadata(Arc::new(metadata_builder.build()?.metadata));

Review Comment:
   this is a very good point.  I did notice people are confused with the usage 
of tx.apply in other discussions, and making `with_metadata` consume tables 
would require `tx.apply` to return `Result<Table>` instead of `Result<()>` and 
make it clearer on its usage. 
   
   I've included the change in this PR, please let me know 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