You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "grihabor (via GitHub)" <gi...@apache.org> on 2025/02/01 09:14:02 UTC
[PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
grihabor opened a new pull request, #1598:
URL: https://github.com/apache/iceberg-python/pull/1598
Part of https://github.com/apache/iceberg-python/pull/1561
Closes https://github.com/apache/iceberg-python/pull/822
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2649415003
Thank you! It passed now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#discussion_r1939197397
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
+ return base_metadata
+
+ if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
Review Comment:
```suggestion
existing_ref := base_metadata.refs[update.ref_name]
if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
```
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
+ return base_metadata
+
+ if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
Review Comment:
```suggestion
existing_ref = base_metadata.refs[update.ref_name]
if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#discussion_r1939195894
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
Review Comment:
I think this is a more Pythonic approach:
```suggestion
if update.ref_name not in base_metadata.refs:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2657770025
@kevinjqliu @Fokko Shall we merge this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on code in PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#discussion_r1948730520
##########
pyiceberg/table/update/snapshot.py:
##########
@@ -749,6 +750,28 @@ def _commit(self) -> UpdatesAndRequirements:
"""Apply the pending changes and commit."""
return self._updates, self._requirements
+ def _remove_ref_snapshot(self, ref_name: str) -> ManageSnapshots:
+ """Remove a snapshot ref.
+
+ Args:
+ ref_name: branch / tag name to remove
+ Stages the updates and requirements for the remove-snapshot-ref.
+ Returns
+ This method for chaining
+ """
+ updates = (RemoveSnapshotRefUpdate(ref_name=ref_name),)
Review Comment:
I didn't get it
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
Review Comment:
I don't mind, I believe it was copied from https://github.com/apache/iceberg-python/pull/822
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
+ return base_metadata
+
+ if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
+ raise ValueError(f"Cannot remove {update.ref_name} ref with unknown snapshot {existing_ref.snapshot_id}")
+
+ current_snapshot_id = None if update.ref_name == MAIN_BRANCH else base_metadata.current_snapshot_id
+
+ metadata_refs = {ref_name: ref for ref_name, ref in base_metadata.refs.items() if ref_name != update.ref_name}
Review Comment:
Are you sure we want to modify existing metadata? All the other code in the repo I've seen creates a copy:
```
metadata_updates["refs"] = {**base_metadata.refs, update.ref_name: snapshot_ref}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2660130311
@grihabor Sorry for not following up here, thanks for adding this, let's get this in 🚀
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2648804738
looks like 3.12 failed because of some flaky build:
```
failed to solve: process "/bin/sh -c curl --retry 5 -s -C - [https://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop3.tgz](https://archive.apache.org/dist/spark/spark-$%7BSPARK_VERSION%7D/spark-$%7BSPARK_VERSION%7D-bin-hadoop3.tgz) -o spark-${SPARK_VERSION}-bin-hadoop3.tgz && tar xzf spark-${SPARK_VERSION}-bin-hadoop3.tgz --directory /opt/spark --strip-components 1 && rm -rf spark-${SPARK_VERSION}-bin-hadoop3.tgz" did not complete successfully: exit code: 28
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#discussion_r1939202531
##########
pyiceberg/table/update/snapshot.py:
##########
@@ -749,6 +750,28 @@ def _commit(self) -> UpdatesAndRequirements:
"""Apply the pending changes and commit."""
return self._updates, self._requirements
+ def _remove_ref_snapshot(self, ref_name: str) -> ManageSnapshots:
+ """Remove a snapshot ref.
+
+ Args:
+ ref_name: branch / tag name to remove
+ Stages the updates and requirements for the remove-snapshot-ref.
+ Returns
+ This method for chaining
+ """
+ updates = (RemoveSnapshotRefUpdate(ref_name=ref_name),)
Review Comment:
Interesting, I would also expect that we would store if it is either a tag or a branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2647468438
@Fokko Thank you for review! Ready for another round
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#discussion_r1939200058
##########
pyiceberg/table/update/__init__.py:
##########
@@ -466,6 +466,21 @@ def _(update: SetSnapshotRefUpdate, base_metadata: TableMetadata, context: _Tabl
return base_metadata.model_copy(update=metadata_updates)
+@_apply_table_update.register(RemoveSnapshotRefUpdate)
+def _(update: RemoveSnapshotRefUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
+ if (existing_ref := base_metadata.refs.get(update.ref_name, None)) is None:
+ return base_metadata
+
+ if base_metadata.snapshot_by_id(existing_ref.snapshot_id) is None:
+ raise ValueError(f"Cannot remove {update.ref_name} ref with unknown snapshot {existing_ref.snapshot_id}")
+
+ current_snapshot_id = None if update.ref_name == MAIN_BRANCH else base_metadata.current_snapshot_id
+
+ metadata_refs = {ref_name: ref for ref_name, ref in base_metadata.refs.items() if ref_name != update.ref_name}
Review Comment:
Here we iterate over the complete dict, which is pretty expensive. Since we know that the key exists, we can also do:
```suggestion
metadata_refs = base_metadata.refs
del metadata_refs[update.ref_name]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2630647678
Thanks for splitting this out 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598#issuecomment-2648820748
I retrigger the test, we get intermittent failures from apache archive link
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Implement update for `remove-snapshot-ref` action [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #1598:
URL: https://github.com/apache/iceberg-python/pull/1598
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org