@@ -24,7 +24,7 @@ use std::fmt::{Display, Formatter};
2424use std:: sync:: Arc ;
2525
2626use _serde:: TableMetadataEnum ;
27- use chrono:: { DateTime , TimeZone , Utc } ;
27+ use chrono:: { DateTime , Utc } ;
2828use serde:: { Deserialize , Serialize } ;
2929use serde_repr:: { Deserialize_repr , Serialize_repr } ;
3030use uuid:: Uuid ;
@@ -33,7 +33,7 @@ use super::snapshot::{Snapshot, SnapshotReference, SnapshotRetention};
3333use super :: {
3434 PartitionSpec , PartitionSpecRef , SchemaId , SchemaRef , SnapshotRef , SortOrder , SortOrderRef ,
3535} ;
36- use crate :: error:: Result ;
36+ use crate :: error:: { timestamp_ms_to_utc , Result } ;
3737use crate :: { Error , ErrorKind , TableCreation } ;
3838
3939static MAIN_BRANCH : & str = "main" ;
@@ -143,8 +143,14 @@ impl TableMetadata {
143143
144144 /// Returns last updated time.
145145 #[ inline]
146- pub fn last_updated_ms ( & self ) -> DateTime < Utc > {
147- Utc . timestamp_millis_opt ( self . last_updated_ms ) . unwrap ( )
146+ pub fn last_updated_timestamp ( & self ) -> Result < DateTime < Utc > > {
147+ timestamp_ms_to_utc ( self . last_updated_ms )
148+ }
149+
150+ /// Returns last updated time in milliseconds.
151+ #[ inline]
152+ pub fn last_updated_ms ( & self ) -> i64 {
153+ self . last_updated_ms
148154 }
149155
150156 /// Returns schemas
@@ -328,7 +334,7 @@ impl TableMetadataBuilder {
328334
329335 let table_metadata = TableMetadata {
330336 format_version : FormatVersion :: V2 ,
331- table_uuid : Uuid :: new_v4 ( ) ,
337+ table_uuid : Uuid :: now_v7 ( ) ,
332338 location : location. ok_or_else ( || {
333339 Error :: new (
334340 ErrorKind :: DataInvalid ,
@@ -472,7 +478,7 @@ pub(super) mod _serde {
472478
473479 /// Helper to serialize and deserialize the format version.
474480 #[ derive( Debug , PartialEq , Eq ) ]
475- pub ( super ) struct VersionNumber < const V : u8 > ;
481+ pub ( crate ) struct VersionNumber < const V : u8 > ;
476482
477483 impl Serialize for TableMetadata {
478484 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
@@ -903,8 +909,14 @@ pub struct SnapshotLog {
903909
904910impl SnapshotLog {
905911 /// Returns the last updated timestamp as a DateTime<Utc> with millisecond precision
906- pub fn timestamp ( self ) -> DateTime < Utc > {
907- Utc . timestamp_millis_opt ( self . timestamp_ms ) . unwrap ( )
912+ pub fn timestamp ( self ) -> Result < DateTime < Utc > > {
913+ timestamp_ms_to_utc ( self . timestamp_ms )
914+ }
915+
916+ /// Returns the timestamp in milliseconds
917+ #[ inline]
918+ pub fn timestamp_ms ( & self ) -> i64 {
919+ self . timestamp_ms
908920 }
909921}
910922
0 commit comments