-
Notifications
You must be signed in to change notification settings - Fork 302
Support snapshot management operations like creating tags by adding ManageSnapshots
API
#728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5f129b6
create API for set_ref_snapshot
chinmay-bhat ed2e647
remove parent_snapshot_id, add AssertTableUUID
chinmay-bhat fb3e25c
wrap `set_ref_snapshot` API in Table
chinmay-bhat aee9c31
rename variable to match `SetSnapshotRefUpdate`
chinmay-bhat 8cd7846
add tests for table and transaction api
chinmay-bhat b6f8596
hide set_ref_snapshot from public API
chinmay-bhat 815cf1f
deprecate add_snapshot()
chinmay-bhat 1c70f62
add create_tag, create_branch apis
chinmay-bhat 6c1e78f
small updates
chinmay-bhat ed05dc9
update tests
chinmay-bhat 6447f6c
expose ManageSnapshot to Table
chinmay-bhat 0349bbe
rename transaction to _transaction
chinmay-bhat 1343d45
apply suggestions
chinmay-bhat 6537229
update only if there are updates
chinmay-bhat 042a1e7
add docstring
chinmay-bhat fbfd463
remove print
chinmay-bhat 8cf9a8c
update to integration tests
chinmay-bhat 5ba32f1
resolve mypy error: does not explicitly export attribute
chinmay-bhat febd36b
improve docstring
chinmay-bhat 5d2b20e
fix failing tests
chinmay-bhat 5f54ff9
move AssertRef to _set_ref_snapshot
chinmay-bhat 8a923a4
remove unused parent_snapshot_id
chinmay-bhat 658c45e
improve docstring for public api manage_snapshots()
chinmay-bhat 97f142a
rename tests
chinmay-bhat 603d5b3
update docs
chinmay-bhat 1eba937
update commit()
chinmay-bhat fe686fc
update tests
chinmay-bhat 1f32a6f
update docs
chinmay-bhat 9f068a6
remove AssertTableUUID
chinmay-bhat 41f5f16
rename test file to fix mypy error
chinmay-bhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
import pytest | ||
|
||
from pyiceberg.catalog import Catalog | ||
from pyiceberg.table.refs import SnapshotRef | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_create_tag(catalog: Catalog) -> None: | ||
identifier = "default.test_table_snapshot_operations" | ||
tbl = catalog.load_table(identifier) | ||
assert len(tbl.history()) > 3 | ||
tag_snapshot_id = tbl.history()[-3].snapshot_id | ||
tbl.manage_snapshots().create_tag(snapshot_id=tag_snapshot_id, tag_name="tag123").commit() | ||
assert tbl.metadata.refs["tag123"] == SnapshotRef(snapshot_id=tag_snapshot_id, snapshot_ref_type="tag") | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_create_branch(catalog: Catalog) -> None: | ||
identifier = "default.test_table_snapshot_operations" | ||
tbl = catalog.load_table(identifier) | ||
assert len(tbl.history()) > 2 | ||
branch_snapshot_id = tbl.history()[-2].snapshot_id | ||
tbl.manage_snapshots().create_branch(snapshot_id=branch_snapshot_id, branch_name="branch123").commit() | ||
assert tbl.metadata.refs["branch123"] == SnapshotRef(snapshot_id=branch_snapshot_id, snapshot_ref_type="branch") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.