Skip to content

Conversation

@HeartLinked
Copy link
Contributor

No description provided.

@HeartLinked HeartLinked changed the title feat: implement update location feat: implement set snapshot Jan 13, 2026

/// \brief Create a new SetSnapshot to set the current snapshot or rollback to a
/// previous snapshot and commit the changes.
virtual Result<std::shared_ptr<SetSnapshot>> NewSetSnapshot();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this since the Java impl only adds to transaction not table.

class UpdateSchema;
class UpdateSortOrder;
class ExpireSnapshots;
class SetSnapshot;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it before SnapshotUpdate


std::optional<std::shared_ptr<Snapshot>> last_snapshot = std::nullopt;
ICEBERG_ASSIGN_OR_RAISE(auto ancestors, AncestorsOf(table, current));
for (const auto& snapshot : ancestors) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this change.

int64_t invalid_snapshot_id = 9999999999999999;
set_snapshot->SetCurrentSnapshot(invalid_snapshot_id);

// Should fail during Apply
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Should fail during Apply

// Rollback to the oldest snapshot (which is an ancestor)
set_snapshot->RollbackTo(kOldestSnapshotId);

// Apply and verify
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Apply and verify

TEST_F(SetSnapshotTest, RollbackToTimeExactMatch) {
ICEBERG_UNWRAP_OR_FAIL(auto set_snapshot, table_->NewSetSnapshot());
// Rollback to a timestamp just after the oldest snapshot
// This should return the oldest snapshot (the latest one before this time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This should return the oldest snapshot (the latest one before this time)

Comment on lines +143 to +146
// Apply without making any changes (NOOP)
ICEBERG_UNWRAP_OR_FAIL(auto snapshot_id, set_snapshot->Apply());

// Should return current snapshot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Apply without making any changes (NOOP)
ICEBERG_UNWRAP_OR_FAIL(auto snapshot_id, set_snapshot->Apply());
// Should return current snapshot
ICEBERG_UNWRAP_OR_FAIL(auto snapshot_id, set_snapshot->Apply());

// Should return current snapshot
EXPECT_EQ(snapshot_id, kCurrentSnapshotId);

// Commit NOOP and verify nothing changed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Commit NOOP and verify nothing changed

}
auto current_timestamp = snapshot->timestamp_ms;
if (current_timestamp < target_timestamp && current_timestamp > latest_timestamp) {
latest_timestamp = current_timestamp; // Save timestamp before move
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function can return Result<std::optional<int64_t> now.

Comment on lines +107 to +108
auto current_result = metadata.Snapshot();
ICEBERG_ACTION_FOR_NOT_FOUND(current_result, return {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we return the error as is if current snapshot is missing? The current approach may confuse the caller that the current snapshot exists but it does not have any ancestor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants