@@ -22,16 +22,19 @@ use std::collections::HashMap;
22
22
use std:: sync:: Arc ;
23
23
24
24
use _serde:: SnapshotV2 ;
25
- use chrono:: { DateTime , TimeZone , Utc } ;
25
+ use chrono:: { DateTime , Utc } ;
26
26
use serde:: { Deserialize , Serialize } ;
27
27
use typed_builder:: TypedBuilder ;
28
28
29
29
use super :: table_metadata:: SnapshotLog ;
30
- use crate :: error:: Result ;
30
+ use crate :: error:: { timestamp_ms_to_utc , Result } ;
31
31
use crate :: io:: FileIO ;
32
32
use crate :: spec:: { ManifestList , SchemaId , SchemaRef , StructType , TableMetadata } ;
33
33
use crate :: { Error , ErrorKind } ;
34
34
35
+ /// The ref name of the main branch of the table.
36
+ pub const MAIN_BRANCH : & str = "main" ;
37
+
35
38
/// Reference to [`Snapshot`].
36
39
pub type SnapshotRef = Arc < Snapshot > ;
37
40
#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq , Clone ) ]
@@ -125,8 +128,14 @@ impl Snapshot {
125
128
}
126
129
/// Get the timestamp of when the snapshot was created
127
130
#[ inline]
128
- pub fn timestamp ( & self ) -> DateTime < Utc > {
129
- Utc . timestamp_millis_opt ( self . timestamp_ms ) . unwrap ( )
131
+ pub fn timestamp ( & self ) -> Result < DateTime < Utc > > {
132
+ timestamp_ms_to_utc ( self . timestamp_ms )
133
+ }
134
+
135
+ /// Get the timestamp of when the snapshot was created in milliseconds
136
+ #[ inline]
137
+ pub fn timestamp_ms ( & self ) -> i64 {
138
+ self . timestamp_ms
130
139
}
131
140
132
141
/// Get the schema id of this snapshot.
@@ -386,8 +395,9 @@ mod tests {
386
395
assert_eq ! ( 3051729675574597004 , result. snapshot_id( ) ) ;
387
396
assert_eq ! (
388
397
Utc . timestamp_millis_opt( 1515100955770 ) . unwrap( ) ,
389
- result. timestamp( )
398
+ result. timestamp( ) . unwrap ( )
390
399
) ;
400
+ assert_eq ! ( 1515100955770 , result. timestamp_ms( ) ) ;
391
401
assert_eq ! (
392
402
Summary {
393
403
operation: Operation :: Append ,
0 commit comments