@@ -399,7 +399,7 @@ nlohmann::json ToJson(const Snapshot& snapshot) {
399399 json[kTimestampMs ] = UnixMsFromTimePointMs (snapshot.timestamp_ms );
400400 json[kManifestList ] = snapshot.manifest_list ;
401401 // If there is an operation, write the summary map
402- if (snapshot.operation ().has_value ()) {
402+ if (snapshot.Operation ().has_value ()) {
403403 json[kSummary ] = snapshot.summary ;
404404 }
405405 SetOptionalField (json, kSchemaId , snapshot.schema_id );
@@ -645,9 +645,8 @@ Result<std::unique_ptr<Snapshot>> SnapshotFromJson(const nlohmann::json& json) {
645645 ICEBERG_ASSIGN_OR_RAISE (auto snapshot_id, GetJsonValue<int64_t >(json, kSnapshotId ));
646646 ICEBERG_ASSIGN_OR_RAISE (auto sequence_number,
647647 GetJsonValueOptional<int64_t >(json, kSequenceNumber ));
648- ICEBERG_ASSIGN_OR_RAISE (
649- auto timestamp_ms,
650- GetJsonValue<int64_t >(json, kTimestampMs ).and_then (TimePointMsFromUnixMs));
648+ ICEBERG_ASSIGN_OR_RAISE (auto unix_ms, GetJsonValue<int64_t >(json, kTimestampMs ));
649+ auto timestamp_ms = TimePointMsFromUnixMs (unix_ms);
651650 ICEBERG_ASSIGN_OR_RAISE (auto manifest_list,
652651 GetJsonValue<std::string>(json, kManifestList ));
653652
@@ -781,9 +780,8 @@ nlohmann::json ToJson(const SnapshotLogEntry& snapshot_log_entry) {
781780
782781Result<SnapshotLogEntry> SnapshotLogEntryFromJson (const nlohmann::json& json) {
783782 SnapshotLogEntry snapshot_log_entry;
784- ICEBERG_ASSIGN_OR_RAISE (
785- snapshot_log_entry.timestamp_ms ,
786- GetJsonValue<int64_t >(json, kTimestampMs ).and_then (TimePointMsFromUnixMs));
783+ ICEBERG_ASSIGN_OR_RAISE (auto unix_ms, GetJsonValue<int64_t >(json, kTimestampMs ));
784+ snapshot_log_entry.timestamp_ms = TimePointMsFromUnixMs (unix_ms);
787785 ICEBERG_ASSIGN_OR_RAISE (snapshot_log_entry.snapshot_id ,
788786 GetJsonValue<int64_t >(json, kSnapshotId ));
789787 return snapshot_log_entry;
@@ -798,9 +796,8 @@ nlohmann::json ToJson(const MetadataLogEntry& metadata_log_entry) {
798796
799797Result<MetadataLogEntry> MetadataLogEntryFromJson (const nlohmann::json& json) {
800798 MetadataLogEntry metadata_log_entry;
801- ICEBERG_ASSIGN_OR_RAISE (
802- metadata_log_entry.timestamp_ms ,
803- GetJsonValue<int64_t >(json, kTimestampMs ).and_then (TimePointMsFromUnixMs));
799+ ICEBERG_ASSIGN_OR_RAISE (auto unix_ms, GetJsonValue<int64_t >(json, kTimestampMs ));
800+ metadata_log_entry.timestamp_ms = TimePointMsFromUnixMs (unix_ms);
804801 ICEBERG_ASSIGN_OR_RAISE (metadata_log_entry.metadata_file ,
805802 GetJsonValue<std::string>(json, kMetadataFile ));
806803 return metadata_log_entry;
@@ -1553,9 +1550,17 @@ Result<std::unique_ptr<TableUpdate>> TableUpdateFromJson(const nlohmann::json& j
15531550 GetJsonValueOptional<int64_t >(json, kMaxSnapshotAgeMs ));
15541551 ICEBERG_ASSIGN_OR_RAISE (auto max_ref_age,
15551552 GetJsonValueOptional<int64_t >(json, kMaxRefAgeMs ));
1556- return std::make_unique<table::SetSnapshotRef>(std::move (ref_name), snapshot_id, type,
1557- min_snapshots, max_snapshot_age,
1558- max_ref_age);
1553+ if (type == SnapshotRefType::kTag ) {
1554+ ICEBERG_ASSIGN_OR_RAISE (auto tag, SnapshotRef::MakeTag (snapshot_id, max_ref_age));
1555+ return std::make_unique<table::SetSnapshotRef>(std::move (ref_name), *tag);
1556+ } else {
1557+ ICEBERG_CHECK (type == SnapshotRefType::kBranch ,
1558+ " Expected branch type for snapshot ref" );
1559+ ICEBERG_ASSIGN_OR_RAISE (auto branch,
1560+ SnapshotRef::MakeBranch (snapshot_id, min_snapshots,
1561+ max_snapshot_age, max_ref_age));
1562+ return std::make_unique<table::SetSnapshotRef>(std::move (ref_name), *branch);
1563+ }
15591564 }
15601565 if (action == kActionSetProperties ) {
15611566 using StringMap = std::unordered_map<std::string, std::string>;
0 commit comments