Skip to content

Clear updates/requirements after commit #1961

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 10 commits into from
Aug 4, 2025
Merged

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented May 2, 2025

Rationale for this change

Resolves #1946

Are these changes tested?

Yes, using a test that used to fail before :)

Are there any user-facing changes?

Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +991 to +998
if len(self._updates) > 0:
self._table._do_commit( # pylint: disable=W0212
updates=self._updates,
requirements=(AssertCreate(),),
)

self._updates = ()
self._requirements = ()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we use super().commit_transaction here?

I want to make sure there's a way for future subclass of Transaction to also clear the updates and requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +997 to +998
self._updates = ()
self._requirements = ()
Copy link
Contributor Author

@Fokko Fokko Aug 4, 2025

Choose a reason for hiding this comment

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

We could refactor it like:

Suggested change
self._updates = ()
self._requirements = ()
super().commit_transaction()

But it doesn't actually commit, but just clear the self_requirements, which is also a bit confusing to me. For me, it makes less sense to commit a CreateTableTransaction twice in the first place. With the original version, it would just error since the table is already created.

Comment on lines +991 to +998
if len(self._updates) > 0:
self._table._do_commit( # pylint: disable=W0212
updates=self._updates,
requirements=(AssertCreate(),),
)

self._updates = ()
self._requirements = ()
Copy link
Contributor

Choose a reason for hiding this comment

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

ah we cant use super().commit_transaction() here because the base Transaction class' commit_transaction() method adds a AssertTableUUID(uuid=self.table_metadata.table_uuid), as a requirement.

Since requirements are checked before updates, this wont work.

👍 im fine with leaving it as is.
We just need to remember to clear _updates and _requirements for future subclasses of Transaction. And hopefully we'll follow the same pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly. The AssertTableUUID is orthogonal to the CreateTable operation, thanks for checking 👍

@Fokko Fokko merged commit 3e391a7 into apache:main Aug 4, 2025
10 checks passed
gabeiglio pushed a commit to Netflix/iceberg-python that referenced this pull request Aug 13, 2025
# Rationale for this change

Resolves apache#1946

# Are these changes tested?

Yes, using a test that used to fail before :)

# Are there any user-facing changes?

<!-- In the case of user-facing changes, please add the changelog label.
-->
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.

Issue in multiple appends in one transaction
4 participants