Skip to content

Commit 107cd63

Browse files
committed
fix review
1 parent 1837ed7 commit 107cd63

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/iceberg/table_metadata.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,11 @@ Status TableMetadataBuilder::Impl::SetBranchSnapshot(int64_t snapshot_id,
10931093
// change is a noop
10941094
return {};
10951095
}
1096-
ICEBERG_ASSIGN_OR_RAISE(auto snapshot, metadata_.SnapshotById(snapshot_id));
1097-
return SetBranchSnapshotInternal(*snapshot, branch);
1096+
1097+
auto snapshot_it = snapshots_by_id_.find(snapshot_id);
1098+
ICEBERG_CHECK(snapshot_it != snapshots_by_id_.end(),
1099+
"Cannot set {} to unknown snapshot: {}", branch, snapshot_id);
1100+
return SetBranchSnapshotInternal(*snapshot_it->second, branch);
10981101
}
10991102

11001103
Status TableMetadataBuilder::Impl::SetBranchSnapshot(std::shared_ptr<Snapshot> snapshot,

src/iceberg/update/pending_update.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class ICEBERG_EXPORT PendingUpdate : public ErrorCollector {
4343
public:
4444
enum class Kind : uint8_t {
4545
kExpireSnapshots,
46+
kSetSnapshot,
4647
kUpdatePartitionSpec,
4748
kUpdateProperties,
4849
kUpdateSchema,
4950
kUpdateSnapshot,
5051
kUpdateSortOrder,
51-
kSetSnapshot,
5252
};
5353

5454
/// \brief Return the kind of this pending update.

src/iceberg/update/set_snapshot.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ SetSnapshot::SetSnapshot(std::shared_ptr<Transaction> transaction)
4646
SetSnapshot::~SetSnapshot() = default;
4747

4848
SetSnapshot& SetSnapshot::SetCurrentSnapshot(int64_t snapshot_id) {
49-
const TableMetadata& base_metadata = transaction_->current();
50-
5149
// Validate that the snapshot exists
52-
auto snapshot_result = base_metadata.SnapshotById(snapshot_id);
50+
auto snapshot_result = base().SnapshotById(snapshot_id);
5351
ICEBERG_BUILDER_CHECK(snapshot_result.has_value(),
5452
"Cannot roll back to unknown snapshot id: {}", snapshot_id);
5553

@@ -74,10 +72,8 @@ SetSnapshot& SetSnapshot::RollbackToTime(int64_t timestamp_ms) {
7472
}
7573

7674
SetSnapshot& SetSnapshot::RollbackTo(int64_t snapshot_id) {
77-
const TableMetadata& current = transaction_->current();
78-
7975
// Validate that the snapshot exists
80-
auto snapshot_result = current.SnapshotById(snapshot_id);
76+
auto snapshot_result = base().SnapshotById(snapshot_id);
8177
ICEBERG_BUILDER_CHECK(snapshot_result.has_value(),
8278
"Cannot roll back to unknown snapshot id: {}", snapshot_id);
8379

src/iceberg/update/set_snapshot.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
namespace iceberg {
3535

3636
/// \brief Sets the current snapshot directly or by rolling back.
37-
///
38-
/// This update is not exposed through the Table API. Instead, it is a package-private
39-
/// part of the Transaction API intended for use in ManageSnapshots.
40-
///
41-
/// When committing, these changes will be applied to the current table metadata.
42-
/// Commit conflicts will not be resolved and will result in a CommitFailed error.
4337
class ICEBERG_EXPORT SetSnapshot : public PendingUpdate {
4438
public:
4539
static Result<std::shared_ptr<SetSnapshot>> Make(

0 commit comments

Comments
 (0)