Repository navigation
Fix UpdateStatistics.remove_statistics overwriting prior queued updates - #4488
Merged
Merged
Conversation
UpdateStatistics.remove_statistics() assigned self._updates = (...) instead of appending via self._updates += (...), silently discarding any preceding set_statistics() or remove_statistics() calls queued in the same UpdateStatistics batch or context manager. Append the RemoveStatisticsUpdate to self._updates so chained and context-manager statistics updates preserve all pending operations, matching the documented UpdateStatistics behavior.
Fokko
self-requested a review
November 30, 2026 17:40
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
UpdateStatistics.remove_statistics()assignedself._updates = (RemoveStatisticsUpdate(snapshot_id=snapshot_id),)instead of appending via+=. As a result, chainingset_statistics(...).remove_statistics(...), using the context manager pattern shown in theUpdateStatisticsandTable.update_statistics()docstrings, or callingremove_statistics()multiple times in one update silently discarded all previously queued updates.This change switches
self._updates = (...)toself._updates += (...)inUpdateStatistics.remove_statistics(), preserving all pending statistics updates in the batch.Are these changes tested?
Yes. Added end-to-end catalog tests in
tests/table/test_update_statistics.py(no mocks, running across thememory,sql, andsql_without_rowcountcatalog fixtures):test_update_statistics_set_and_remove_in_one_update(chained, context-manager, and reverse order)test_update_statistics_multiple_removals_in_one_updatetest_update_statistics_set_and_remove_in_transactionConfirmed all 9 parametrized test cases fail prior to the fix (
9 failed) and pass after the fix (9 passed), along withtests/table/test_statistics.pyandruff/ty/codespellchecks.Are there any user-facing changes?
Yes. Calling
remove_statistics()afterset_statistics()or anotherremove_statistics()in the sameUpdateStatisticsbatch or context manager now preserves and commits all queued updates instead of silently dropping earlier ones.