File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 99//! All changes are made atomically - either all updates succeed or none are applied.
1010//! Requirements are checked first to ensure concurrent modifications don't corrupt state.
1111
12- use std:: collections:: HashMap ;
13-
1412use iceberg_rust_spec:: {
1513 spec:: {
1614 partition:: PartitionSpec ,
@@ -24,6 +22,8 @@ use iceberg_rust_spec::{
2422 view_metadata:: Materialization ,
2523} ;
2624use serde_derive:: { Deserialize , Serialize } ;
25+ use std:: collections:: HashMap ;
26+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
2727use uuid:: Uuid ;
2828
2929use crate :: error:: Error ;
@@ -530,6 +530,12 @@ pub fn apply_table_updates(
530530 }
531531 } ;
532532 }
533+
534+ // Lastly make sure `last-updated-ms` field is up-to-date
535+ metadata. last_updated_ms = SystemTime :: now ( )
536+ . duration_since ( UNIX_EPOCH )
537+ . unwrap ( )
538+ . as_millis ( ) as i64 ;
533539 Ok ( ( ) )
534540}
535541
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ async fn test_table_transaction_overwrite() {
8383 . await
8484 . expect ( "Failed to create table" ) ;
8585
86+ let mut previous_last_updated_ms = table. metadata ( ) . last_updated_ms ;
87+
8688 // 4. Create initial Arrow RecordBatch and write to parquet
8789 let initial_batch = create_initial_record_batch ( ) ;
8890 let initial_stream = stream:: iter ( vec ! [ Ok ( initial_batch. clone( ) ) ] ) ;
@@ -104,6 +106,8 @@ async fn test_table_transaction_overwrite() {
104106 !table. metadata( ) . snapshots. is_empty( ) ,
105107 "Table should have at least one snapshot after append"
106108 ) ;
109+ assert ! ( table. metadata( ) . last_updated_ms > previous_last_updated_ms) ;
110+ previous_last_updated_ms = table. metadata ( ) . last_updated_ms ;
107111
108112 // 6. Create overwrite RecordBatch with additional rows
109113 let overwrite_batch = create_overwrite_record_batch ( ) ;
@@ -134,6 +138,7 @@ async fn test_table_transaction_overwrite() {
134138 final_snapshots. len( ) >= 2 ,
135139 "Table should have at least 2 snapshots after overwrite"
136140 ) ;
141+ assert ! ( table. metadata( ) . last_updated_ms > previous_last_updated_ms) ;
137142
138143 // Get the current snapshot (should be the overwrite snapshot)
139144 let current_snapshot = table
You can’t perform that action at this time.
0 commit comments