Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces validation checks in MutationsBatcher.mutate to ensure that only DirectRow instances are processed and that the row's table matches the batcher's table. Corresponding unit tests have been added to verify these validations. The review feedback suggests using f-strings instead of % formatting for better readability and correcting a typo ('can not' to 'cannot') in the error message.
mutianf
force-pushed
the
fix-batcher-row-validation
branch
from
October 28, 2026 19:30
6f5cff0 to
be1f1fd
Compare
This branch has not been deployed
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.
Summary
Validate that rows passed to
MutationsBatcher.mutate(row)(and by extensionMutationsBatcher.mutate_rows(rows)) are instances ofDirectRowand are not bound to a different table, matching the existing validation inTable.mutate_rows().Problem
When
MutationsBatcherwas refactored to wrapself.table._table_impl.mutations_batcher(...)directly (#18200) instead of delegating toself.table.mutate_rows(...), two row-validation checks fromTable.mutate_rows()were dropped:DirectRowtype check (TypeError): Passing aConditionalRowtobatcher.mutate(cond_row)calledcond_row._get_mutations()with the defaultstate=None, which returnsself._false_pb_mutationsand unconditionally sends false-branch mutations viaMutateRowswithout evaluating the row filter predicate. Passing anAppendRowraised a rawAttributeError: 'AppendRow' object has no attribute '_get_mutations'instead ofTypeError.TableMismatchError): Passing aDirectRowbound to another table silently sent its mutations tobatcher.tableinstead of raisingTableMismatchError.Solution
isinstance(row, DirectRow)inMutationsBatcher.mutate(), raisingTypeError("Bulk processing can not be applied for conditional or append mutations.")if not.row.table is None or row.table.name == self.table.nameinMutationsBatcher.mutate(), raisingTableMismatchErrorif the row belongs to a different table.:raises:(TypeErrorandTableMismatchError) onMutationsBatcher.mutate()andMutationsBatcher.mutate_rows().Test Plan
packages/google-cloud-bigtable/tests/unit/v2_client/test_batcher.py:test_mutations_batcher_mutate_w_bound_table_rowtest_mutations_batcher_mutate_wrong_row_type(ConditionalRowandAppendRowacrossmutateandmutate_rows, verifying no mutations are queued)test_mutations_batcher_mutate_table_mismatch(cross-tableDirectRowacrossmutateandmutate_rows)