c-thiel commented on code in PR #331:
URL: https://github.com/apache/iceberg-rust/pull/331#discussion_r1690897640
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -917,8 +933,24 @@ pub struct SnapshotLog {
impl SnapshotLog {
/// Returns the last updated timestamp as a DateTime<Utc> with millisecond
precision
- pub fn timestamp(self) -> DateTime<Utc> {
- Utc.timestamp_millis_opt(self.timestamp_ms).unwrap()
+ pub fn timestamp(self) -> Result<DateTime<Utc>> {
+ match Utc.timestamp_millis_opt(self.timestamp_ms) {
+ MappedLocalTime::Single(t) => Ok(t),
+ MappedLocalTime::Ambiguous(_, _) => Err(Error::new(
+ ErrorKind::Unexpected,
+ "Ambiguous timestamp in snapshot log",
+ )),
+ MappedLocalTime::None => Err(Error::new(
+ ErrorKind::Unexpected,
+ "Invalid timestamp in snapshot log",
Review Comment:
https://github.com/c-thiel/iceberg-rust/commit/ea7f2ea9e35be6d4f42e89a9e22938661272e209
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -917,8 +933,24 @@ pub struct SnapshotLog {
impl SnapshotLog {
/// Returns the last updated timestamp as a DateTime<Utc> with millisecond
precision
- pub fn timestamp(self) -> DateTime<Utc> {
- Utc.timestamp_millis_opt(self.timestamp_ms).unwrap()
+ pub fn timestamp(self) -> Result<DateTime<Utc>> {
+ match Utc.timestamp_millis_opt(self.timestamp_ms) {
+ MappedLocalTime::Single(t) => Ok(t),
+ MappedLocalTime::Ambiguous(_, _) => Err(Error::new(
+ ErrorKind::Unexpected,
+ "Ambiguous timestamp in snapshot log",
Review Comment:
https://github.com/c-thiel/iceberg-rust/commit/ea7f2ea9e35be6d4f42e89a9e22938661272e209
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]