@@ -22,16 +22,19 @@ use std::collections::HashMap;
2222use std:: sync:: Arc ;
2323
2424use _serde:: SnapshotV2 ;
25- use chrono:: { DateTime , TimeZone , Utc } ;
25+ use chrono:: { DateTime , Utc } ;
2626use serde:: { Deserialize , Serialize } ;
2727use typed_builder:: TypedBuilder ;
2828
2929use super :: table_metadata:: SnapshotLog ;
30- use crate :: error:: Result ;
30+ use crate :: error:: { timestamp_ms_to_utc , Result } ;
3131use crate :: io:: FileIO ;
3232use crate :: spec:: { ManifestList , SchemaId , SchemaRef , StructType , TableMetadata } ;
3333use crate :: { Error , ErrorKind } ;
3434
35+ /// The ref name of the main branch of the table.
36+ pub const MAIN_BRANCH : & str = "main" ;
37+
3538/// Reference to [`Snapshot`].
3639pub type SnapshotRef = Arc < Snapshot > ;
3740#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq , Clone ) ]
@@ -125,8 +128,14 @@ impl Snapshot {
125128 }
126129 /// Get the timestamp of when the snapshot was created
127130 #[ 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
130139 }
131140
132141 /// Get the schema id of this snapshot.
@@ -386,8 +395,9 @@ mod tests {
386395 assert_eq ! ( 3051729675574597004 , result. snapshot_id( ) ) ;
387396 assert_eq ! (
388397 Utc . timestamp_millis_opt( 1515100955770 ) . unwrap( ) ,
389- result. timestamp( )
398+ result. timestamp( ) . unwrap ( )
390399 ) ;
400+ assert_eq ! ( 1515100955770 , result. timestamp_ms( ) ) ;
391401 assert_eq ! (
392402 Summary {
393403 operation: Operation :: Append ,
0 commit comments