@@ -20,7 +20,7 @@ Defines the [table metadata](https://iceberg.apache.org/spec/#table-metadata).
20
20
The main struct here is [TableMetadataV2] which defines the data for a table.
21
21
*/
22
22
23
- use crate :: spec:: timestamp :: Timestamp ;
23
+ use crate :: spec:: timestamp_millis :: TimestampMillis ;
24
24
use serde:: { Deserialize , Serialize } ;
25
25
use serde_repr:: { Deserialize_repr , Serialize_repr } ;
26
26
use std:: { collections:: HashMap , sync:: Arc } ;
@@ -53,7 +53,7 @@ pub struct TableMetadata {
53
53
/// The tables highest sequence number
54
54
last_sequence_number : i64 ,
55
55
/// Timestamp in milliseconds from the unix epoch when the table was last updated.
56
- last_updated_ms : Timestamp ,
56
+ last_updated_ms : i64 ,
57
57
/// An integer; the highest assigned column ID for the table.
58
58
last_column_id : i32 ,
59
59
/// A list of schemas, stored as objects with schema-id.
@@ -134,8 +134,8 @@ impl TableMetadata {
134
134
135
135
/// Returns last updated time.
136
136
#[ inline]
137
- pub fn last_updated_ms ( & self ) -> Timestamp {
138
- self . last_updated_ms
137
+ pub fn last_updated_ms ( & self ) -> TimestampMillis {
138
+ TimestampMillis :: new ( self . last_updated_ms )
139
139
}
140
140
141
141
/// Returns schemas
@@ -243,7 +243,7 @@ impl TableMetadata {
243
243
244
244
/// Append snapshot to table
245
245
pub fn append_snapshot ( & mut self , snapshot : Snapshot ) {
246
- self . last_updated_ms = snapshot. timestamp ( ) ;
246
+ self . last_updated_ms = snapshot. timestamp ( ) . to_date_time ( ) . timestamp_millis ( ) ;
247
247
self . last_sequence_number = snapshot. sequence_number ( ) ;
248
248
249
249
self . refs
@@ -279,7 +279,7 @@ pub(super) mod _serde {
279
279
use serde:: { Deserialize , Serialize } ;
280
280
use uuid:: Uuid ;
281
281
282
- use crate :: spec:: Snapshot ;
282
+ use crate :: spec:: { Snapshot , TimestampMillis } ;
283
283
use crate :: {
284
284
spec:: {
285
285
schema:: _serde:: { SchemaV1 , SchemaV2 } ,
@@ -294,8 +294,6 @@ pub(super) mod _serde {
294
294
DEFAULT_SPEC_ID , MAIN_BRANCH ,
295
295
} ;
296
296
297
- use crate :: spec:: timestamp:: Timestamp ;
298
-
299
297
#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
300
298
#[ serde( untagged) ]
301
299
pub ( super ) enum TableMetadataEnum {
@@ -311,7 +309,7 @@ pub(super) mod _serde {
311
309
pub table_uuid : Uuid ,
312
310
pub location : String ,
313
311
pub last_sequence_number : i64 ,
314
- pub last_updated_ms : Timestamp ,
312
+ pub last_updated_ms : TimestampMillis ,
315
313
pub last_column_id : i32 ,
316
314
pub schemas : Vec < SchemaV2 > ,
317
315
pub current_schema_id : i32 ,
@@ -342,7 +340,7 @@ pub(super) mod _serde {
342
340
#[ serde( skip_serializing_if = "Option::is_none" ) ]
343
341
pub table_uuid : Option < Uuid > ,
344
342
pub location : String ,
345
- pub last_updated_ms : Timestamp ,
343
+ pub last_updated_ms : TimestampMillis ,
346
344
pub last_column_id : i32 ,
347
345
pub schema : SchemaV1 ,
348
346
#[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -436,7 +434,7 @@ pub(super) mod _serde {
436
434
table_uuid : value. table_uuid ,
437
435
location : value. location ,
438
436
last_sequence_number : value. last_sequence_number ,
439
- last_updated_ms : value. last_updated_ms ,
437
+ last_updated_ms : value. last_updated_ms . to_date_time ( ) . timestamp_millis ( ) ,
440
438
last_column_id : value. last_column_id ,
441
439
current_schema_id : if schemas. keys ( ) . contains ( & value. current_schema_id ) {
442
440
Ok ( value. current_schema_id )
@@ -544,7 +542,7 @@ pub(super) mod _serde {
544
542
table_uuid : value. table_uuid . unwrap_or_default ( ) ,
545
543
location : value. location ,
546
544
last_sequence_number : 0 ,
547
- last_updated_ms : value. last_updated_ms ,
545
+ last_updated_ms : value. last_updated_ms . to_date_time ( ) . timestamp_millis ( ) ,
548
546
last_column_id : value. last_column_id ,
549
547
current_schema_id : value
550
548
. current_schema_id
@@ -607,7 +605,7 @@ pub(super) mod _serde {
607
605
table_uuid : v. table_uuid ,
608
606
location : v. location ,
609
607
last_sequence_number : v. last_sequence_number ,
610
- last_updated_ms : v. last_updated_ms ,
608
+ last_updated_ms : TimestampMillis :: new ( v. last_updated_ms ) ,
611
609
last_column_id : v. last_column_id ,
612
610
schemas : v
613
611
. schemas
@@ -673,7 +671,7 @@ pub(super) mod _serde {
673
671
format_version : VersionNumber :: < 1 > ,
674
672
table_uuid : Some ( v. table_uuid ) ,
675
673
location : v. location ,
676
- last_updated_ms : v. last_updated_ms ,
674
+ last_updated_ms : TimestampMillis :: new ( v. last_updated_ms ) ,
677
675
last_column_id : v. last_column_id ,
678
676
schema : v
679
677
. schemas
@@ -771,7 +769,7 @@ pub struct SnapshotLog {
771
769
/// Id of the snapshot.
772
770
pub snapshot_id : i64 ,
773
771
/// Last updated timestamp
774
- pub timestamp_ms : Timestamp ,
772
+ pub timestamp_ms : TimestampMillis ,
775
773
}
776
774
777
775
#[ cfg( test) ]
@@ -790,7 +788,7 @@ mod tests {
790
788
SnapshotRetention , SortDirection , SortField , SortOrder , Summary , Transform , Type ,
791
789
} ;
792
790
793
- use crate :: spec:: timestamp :: Timestamp ;
791
+ use crate :: spec:: timestamp_millis :: TimestampMillis ;
794
792
795
793
use super :: { FormatVersion , MetadataLog , SnapshotLog } ;
796
794
@@ -883,7 +881,7 @@ mod tests {
883
881
format_version : FormatVersion :: V2 ,
884
882
table_uuid : Uuid :: parse_str ( "fb072c92-a02b-11e9-ae9c-1bb7bc9eca94" ) . unwrap ( ) ,
885
883
location : "s3://b/wh/data.db/table" . to_string ( ) ,
886
- last_updated_ms : Timestamp :: new ( 1515100955770 ) . unwrap ( ) ,
884
+ last_updated_ms : 1515100955770 ,
887
885
last_column_id : 1 ,
888
886
schemas : HashMap :: from_iter ( vec ! [ ( 1 , Arc :: new( schema) ) ] ) ,
889
887
current_schema_id : 1 ,
@@ -1042,7 +1040,7 @@ mod tests {
1042
1040
1043
1041
let snapshot = Snapshot :: builder ( )
1044
1042
. with_snapshot_id ( 638933773299822130 )
1045
- . with_timestamp_ms ( Timestamp :: new ( 1662532818843 ) . unwrap ( ) )
1043
+ . with_timestamp_ms ( 1662532818843 )
1046
1044
. with_sequence_number ( 0 )
1047
1045
. with_schema_id ( 0 )
1048
1046
. with_manifest_list ( ManifestListLocation :: ManifestListFile ( "/home/iceberg/warehouse/nyc/taxis/metadata/snap-638933773299822130-1-7e6760f0-4f6c-4b23-b907-0a5a174e3863.avro" . to_string ( ) ) )
@@ -1053,7 +1051,7 @@ mod tests {
1053
1051
format_version : FormatVersion :: V1 ,
1054
1052
table_uuid : Uuid :: parse_str ( "df838b92-0b32-465d-a44e-d39936e538b7" ) . unwrap ( ) ,
1055
1053
location : "/home/iceberg/warehouse/nyc/taxis" . to_string ( ) ,
1056
- last_updated_ms : Timestamp :: new ( 1662532818843 ) . unwrap ( ) ,
1054
+ last_updated_ms : 1662532818843 ,
1057
1055
last_column_id : 5 ,
1058
1056
schemas : HashMap :: from_iter ( vec ! [ ( 0 , Arc :: new( schema) ) ] ) ,
1059
1057
current_schema_id : 0 ,
@@ -1068,7 +1066,7 @@ mod tests {
1068
1066
properties : HashMap :: from_iter ( vec ! [ ( "owner" . to_string( ) , "root" . to_string( ) ) ] ) ,
1069
1067
snapshot_log : vec ! [ SnapshotLog {
1070
1068
snapshot_id: 638933773299822130 ,
1071
- timestamp_ms: Timestamp :: new( 1662532818843 ) . unwrap ( ) ,
1069
+ timestamp_ms: TimestampMillis :: new( 1662532818843 ) ,
1072
1070
} ] ,
1073
1071
metadata_log : vec ! [ MetadataLog { metadata_file: "/home/iceberg/warehouse/nyc/taxis/metadata/00000-8a62c37d-4573-4021-952a-c0baef7d21d0.metadata.json" . to_string( ) , timestamp_ms: 1662532805245 } ] ,
1074
1072
refs : HashMap :: from_iter ( vec ! [ ( "main" . to_string( ) , SnapshotReference { snapshot_id: 638933773299822130 , retention: SnapshotRetention :: Branch { min_snapshots_to_keep: None , max_snapshot_age_ms: None , max_ref_age_ms: None } } ) ] )
@@ -1166,7 +1164,7 @@ mod tests {
1166
1164
1167
1165
let snapshot1 = Snapshot :: builder ( )
1168
1166
. with_snapshot_id ( 3051729675574597004 )
1169
- . with_timestamp_ms ( Timestamp :: new ( 1515100955770 ) . unwrap ( ) )
1167
+ . with_timestamp_ms ( 1515100955770 )
1170
1168
. with_sequence_number ( 0 )
1171
1169
. with_manifest_list ( ManifestListLocation :: ManifestListFile (
1172
1170
"s3://a/b/1.avro" . to_string ( ) ,
@@ -1181,7 +1179,7 @@ mod tests {
1181
1179
let snapshot2 = Snapshot :: builder ( )
1182
1180
. with_snapshot_id ( 3055729675574597004 )
1183
1181
. with_parent_snapshot_id ( Some ( 3051729675574597004 ) )
1184
- . with_timestamp_ms ( Timestamp :: new ( 1555100955770 ) . unwrap ( ) )
1182
+ . with_timestamp_ms ( 1555100955770 )
1185
1183
. with_sequence_number ( 1 )
1186
1184
. with_schema_id ( 1 )
1187
1185
. with_manifest_list ( ManifestListLocation :: ManifestListFile (
@@ -1198,7 +1196,7 @@ mod tests {
1198
1196
format_version : FormatVersion :: V2 ,
1199
1197
table_uuid : Uuid :: parse_str ( "9c12d441-03fe-4693-9a96-a0705ddf69c1" ) . unwrap ( ) ,
1200
1198
location : "s3://bucket/test/location" . to_string ( ) ,
1201
- last_updated_ms : Timestamp :: new ( 1602638573590 ) . unwrap ( ) ,
1199
+ last_updated_ms : 1602638573590 ,
1202
1200
last_column_id : 3 ,
1203
1201
schemas : HashMap :: from_iter ( vec ! [ ( 0 , Arc :: new( schema1) ) , ( 1 , Arc :: new( schema2) ) ] ) ,
1204
1202
current_schema_id : 1 ,
@@ -1217,11 +1215,11 @@ mod tests {
1217
1215
snapshot_log : vec ! [
1218
1216
SnapshotLog {
1219
1217
snapshot_id: 3051729675574597004 ,
1220
- timestamp_ms: Timestamp :: new( 1515100955770 ) . unwrap ( ) ,
1218
+ timestamp_ms: TimestampMillis :: new( 1515100955770 ) ,
1221
1219
} ,
1222
1220
SnapshotLog {
1223
1221
snapshot_id: 3055729675574597004 ,
1224
- timestamp_ms: Timestamp :: new( 1555100955770 ) . unwrap ( ) ,
1222
+ timestamp_ms: TimestampMillis :: new( 1555100955770 ) ,
1225
1223
} ,
1226
1224
] ,
1227
1225
metadata_log : Vec :: new ( ) ,
@@ -1299,7 +1297,7 @@ mod tests {
1299
1297
format_version : FormatVersion :: V2 ,
1300
1298
table_uuid : Uuid :: parse_str ( "9c12d441-03fe-4693-9a96-a0705ddf69c1" ) . unwrap ( ) ,
1301
1299
location : "s3://bucket/test/location" . to_string ( ) ,
1302
- last_updated_ms : Timestamp :: new ( 1602638573590 ) . unwrap ( ) ,
1300
+ last_updated_ms : 1602638573590 ,
1303
1301
last_column_id : 3 ,
1304
1302
schemas : HashMap :: from_iter ( vec ! [ ( 0 , Arc :: new( schema) ) ] ) ,
1305
1303
current_schema_id : 0 ,
@@ -1361,7 +1359,7 @@ mod tests {
1361
1359
format_version : FormatVersion :: V1 ,
1362
1360
table_uuid : Uuid :: parse_str ( "d20125c8-7284-442c-9aea-15fee620737c" ) . unwrap ( ) ,
1363
1361
location : "s3://bucket/test/location" . to_string ( ) ,
1364
- last_updated_ms : Timestamp :: new ( 1602638573874 ) . unwrap ( ) ,
1362
+ last_updated_ms : 1602638573874 ,
1365
1363
last_column_id : 3 ,
1366
1364
schemas : HashMap :: from_iter ( vec ! [ ( 0 , Arc :: new( schema) ) ] ) ,
1367
1365
current_schema_id : 0 ,
0 commit comments