Skip to content

Conversation

@zhjwpku
Copy link
Collaborator

@zhjwpku zhjwpku commented Jan 28, 2026

The test cases are derived from Java's TestSnapshotManager.java. Since MergeAppend is not supported yet, some tests are omitted for now and can be added later.

The test cases are derived from Java's TestSnapshotManager.java.
Since MergeAppend is not supported yet, some tests are omitted for
now and can be added later.
Copy link
Contributor

@evindj evindj left a comment

Choose a reason for hiding this comment

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

Overall LGTM only question that I have is why is UpdateSnapshotReference and SnapShotManager both exposed. Also, is there a way we can integration test this change?

protected:
// These snapshot IDs correspond to the snapshots in the TableMetadataV2Valid.json
static constexpr int64_t kOldestSnapshotId = 3051729675574597004;
static constexpr int64_t kCurrentSnapshotId = 3055729675574597004;
Copy link
Contributor

Choose a reason for hiding this comment

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

since the metadata file is read in the base test setup, will it make sense to extract these in variables instead of copy pasta?

/// and tags) and commit the changes.
Result<std::shared_ptr<UpdateSnapshotReference>> NewUpdateSnapshotReference();

/// \brief Create a new SnapshotManager to manage snapshots.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you be a bit more descriptive here especially how it differs from NewUpdateSnapshotReference() I am a little confuse as to why the transaction would expose both since SnapshotManager seems to be a wrapper on top of UpdateSnapshotReference

~SnapshotManager() override;

// TODO(xxx): is this correct?
Kind kind() const final { return Kind::kUpdateSnapshotReference; }
Copy link
Contributor

Choose a reason for hiding this comment

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

According to https://github.com/apache/iceberg-cpp/blob/main/src/iceberg/update/update_snapshot_reference.h this looks correct. But would still probably want to wait for someone who knows more about this space.

Copy link
Member

Choose a reason for hiding this comment

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


SnapshotManager& SnapshotManager::Cherrypick(int64_t snapshot_id) {
ICEBERG_BUILDER_RETURN_IF_ERROR(CommitIfRefUpdatesExist());
// TODO(anyone): Implement cherrypick operation
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue for this?

Copy link
Member

Choose a reason for hiding this comment

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

I guess the reason is the lack of CherryPickOperation implementation.

/// \brief Table update.
class TableMetadataBuilder;
class TableUpdate;
class SnapshotManager;
Copy link
Member

Choose a reason for hiding this comment

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

Should we put it at line 195 below?

///
/// \param branch Which is name of SnapshotRef of type branch
/// \return Reference to this for method chaining
auto& ToBranch(this auto& self, const std::string& branch) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename SetTargetBranch to ToBranch as they are equivalent?

~SnapshotManager() override;

// TODO(xxx): is this correct?
Kind kind() const final { return Kind::kUpdateSnapshotReference; }
Copy link
Member

Choose a reason for hiding this comment

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

/// \param table_name The name of the table
/// \param table The table to manage snapshots for
/// \return A new SnapshotManager instance, or an error if the table doesn't exist
static Result<std::shared_ptr<SnapshotManager>> Make(const std::string& table_name,
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this ctor? transaction internally holds a table which has table_identifier_ to get its name? We are slightly different than Java because we always create a transaction instance in the Table instance to create any update.


SnapshotManager& SnapshotManager::Cherrypick(int64_t snapshot_id) {
ICEBERG_BUILDER_RETURN_IF_ERROR(CommitIfRefUpdatesExist());
// TODO(anyone): Implement cherrypick operation
Copy link
Member

Choose a reason for hiding this comment

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

I guess the reason is the lack of CherryPickOperation implementation.

/// \brief Commit any pending reference updates if they exist.
Status CommitIfRefUpdatesExist();

bool is_external_transaction_;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this. Transaction::auto_commit_ has already taken good care of it.

SnapshotManager& SnapshotManager::CreateBranch(const std::string& name) {
if (base().current_snapshot_id != kInvalidSnapshotId) {
ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto current_snapshot, base().Snapshot());
if (current_snapshot != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

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

It should be an error if current_snapshot_id exists but snapshot is null.

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.

3 participants