Skip to content

Conversation

@gkevinzheng
Copy link
Contributor

Changes made:

  • Row objects hold Mutation and ReadModifyWriteRowRule objects from the data client rather than raw protos.
  • Rerouted ConditionalRow.commit and AppendRow.commit (CheckAndMutateRows and ReadModifyWriteRows respectively) to use the data client, or more specifically, self._table._table_impl
  • Added function DirectRow._to_mutation_pbs for retrieving mutations in proto form for the current MutateRows implementation, as well as for DirectRow.get_mutations_size.
  • Removed unnecessary helper functions and tests for helper functions

@gkevinzheng gkevinzheng requested review from a team as code owners January 16, 2026 17:37
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Jan 16, 2026
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the googleapis/python-bigtable API. label Jan 16, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @gkevinzheng, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the internal handling of mutations and read-modify-write operations within the Bigtable client library. By transitioning Row objects to store data client-specific mutation and rule objects, it modernizes the internal API. This change also reroutes conditional and append row commit operations to utilize a new, more centralized data client implementation, leading to a cleaner and more maintainable codebase.

Highlights

  • Internal API Modernization: Row objects now store higher-level data client Mutation and ReadModifyWriteRowRule objects instead of raw protobufs, simplifying internal data representation.
  • Rerouted Commit Operations: ConditionalRow.commit and AppendRow.commit now leverage the new data client implementation (self._table._table_impl) for CheckAndMutateRows and ReadModifyWriteRows, centralizing API calls.
  • Mutation Proto Conversion: Introduced DirectRow._to_mutation_pbs to convert the new mutation objects into their protobuf form, ensuring compatibility with existing MutateRows and size calculation logic.
  • Code Cleanup: Removed several deprecated helper functions and their associated tests, streamlining the codebase.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant and well-executed refactoring. It replaces direct protobuf manipulation with higher-level data objects like Mutation and ReadModifyWriteRule, which greatly improves code clarity and maintainability. Rerouting the commit methods in ConditionalRow and AppendRow to use the _table_impl abstraction is also a good move towards better separation of concerns. The test suite has been updated thoroughly to reflect these changes.

I have one suggestion in tests/unit/v2_client/test_row.py to improve the robustness of a test helper by aligning its logic more closely with the production code it's testing.

Overall, this is an excellent set of changes that enhances the quality of the codebase.

Comment on lines +304 to +313
expected_mutation = DeleteRangeFromColumn(family=column_family_id, qualifier=column)
if time_range is not None:
expected_pb.delete_from_column.time_range._pb.CopyFrom(time_range._to_pb()._pb)
assert row._pb_mutations == [expected_pb]
time_range_pb = time_range._to_pb()
if time_range_pb.start_timestamp_micros:
expected_mutation.start_timestamp_micros = (
time_range_pb.start_timestamp_micros
)
if time_range_pb.end_timestamp_micros:
expected_mutation.end_timestamp_micros = time_range_pb.end_timestamp_micros
_assert_mutations_equal(row._mutations, [expected_mutation])

Choose a reason for hiding this comment

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

medium

The logic to construct expected_mutation is a bit complex and uses time_range._to_pb(), while the production code in _delete_cells uses time_range._to_dict(). This discrepancy could make the test brittle or hide potential bugs if the two methods diverge.

To improve robustness and readability, I suggest aligning the test with the production code's logic. You could extract the timestamps from time_range._to_dict() and then construct the expected_mutation in a single call.

Suggested change
expected_mutation = DeleteRangeFromColumn(family=column_family_id, qualifier=column)
if time_range is not None:
expected_pb.delete_from_column.time_range._pb.CopyFrom(time_range._to_pb()._pb)
assert row._pb_mutations == [expected_pb]
time_range_pb = time_range._to_pb()
if time_range_pb.start_timestamp_micros:
expected_mutation.start_timestamp_micros = (
time_range_pb.start_timestamp_micros
)
if time_range_pb.end_timestamp_micros:
expected_mutation.end_timestamp_micros = time_range_pb.end_timestamp_micros
_assert_mutations_equal(row._mutations, [expected_mutation])
start_timestamp_micros = None
end_timestamp_micros = None
if time_range is not None:
timestamps = time_range._to_dict()
start_timestamp_micros = timestamps.get("start_timestamp_micros")
end_timestamp_micros = timestamps.get("end_timestamp_micros")
expected_mutation = DeleteRangeFromColumn(
family=column_family_id,
qualifier=column,
start_timestamp_micros=start_timestamp_micros,
end_timestamp_micros=end_timestamp_micros,
)
_assert_mutations_equal(row._mutations, [expected_mutation])

Copy link
Contributor

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

A couple small comments. The only important one is dealing with mutations_list

This is looking really good though, it's great seeing all this code removed!

mutation_val = data_v2_pb2.Mutation.DeleteFromFamily(
family_name=column_family_id
self._get_mutations(state).append(
mutations.DeleteAllFromFamily(family_to_delete=column_family_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like you aren't using mutations_list, but it's still set at the top of the function (and then accessed at the bottom)

delete_kwargs["time_range"] = time_range._to_pb()
timestamps = time_range._to_dict()
start_timestamp_micros = timestamps.get("start_timestamp_micros")
end_timestamp_micros = timestamps.get("end_timestamp_micros")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this logic might be a bit cleaner like this:

timerange_dict = time_range._to_dict() if time_range else {}
start_timestamp_micros = timestamps.get("start_timestamp_micros")
end_timestamp_micros = timestamps.get("end_timestamp_micros")

But it's fine as-is too

for cell in row_response.cells:
result.setdefault(cell.family, {}).setdefault(cell.qualifier, []).append(
(cell.value, _datetime_from_microseconds(cell.timestamp_micros))
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is a bit complex for a one-liner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/python-bigtable API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants