Skip to content

feat: Rerouted ReadRows to data client - #18198

Open
daniel-sanche wants to merge 36 commits into
shim/10-read-rows-rst-streamfrom
shim/11-read-rows-data-client
Open

feat: Rerouted ReadRows to data client#18198
daniel-sanche wants to merge 36 commits into
shim/10-read-rows-rst-streamfrom
shim/11-read-rows-data-client

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Migrating over @gkevinzheng PR from bigtable monorepo googleapis/python-bigtable#1308

Original description:

Changes Made:

  • Added methods to convert Row and Cell objects in the data client to PartialRowData and Cell objects in the legacy client.
  • Removed legacy client code related to processing ReadRowResponse chunks and testing ReadRowResponse chunks.
  • Removed _update_message_request from RowSet because it's no longer needed to create a ReadRowQuery
  • Rerouted read_row and read_rows to use their data client counterparts in table.py.

Additional Changes:

Applied some guards against removed semi-private APIs, after internal discussion:

  • 6941199: we had a couple technically public, but not meant to be accessed attributes. This commit replaces them with properties that raise a warning and return None, rather than completely removing them
  • c9617ac: Similarily, the PartialRowsData constructor was technically public, but not intended to be used. This change returns an empty generator when the previous constructor is used, with a warning
  • b51292e: handles a bug that could occur if None is passed for retries
  • 92da437: added better typing to generator

Note to reviewers: This PR has already been reviewed and merged to a staging branch, with the intention of doing a single merge to main. We are now planning to slowly rollout these changes back to the main branch. Minimal re-review should be necessary

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

Copy link
Copy Markdown
Contributor

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 refactors the Bigtable client to delegate row reading and streaming to the underlying _table_impl data client, deprecating legacy classes like _RowMerger and several attributes on PartialRowsData. The review feedback identifies potential AttributeError risks when accessing retry.deadline directly (since google.api_core.retry.Retry typically uses _deadline internally) in table.py and unit tests, as well as when calling close() on _generator in row_data.py if the generator does not support it.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/table.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/table.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/row_data.py
Comment thread packages/google-cloud-bigtable/tests/unit/v2_client/test_table.py
gkevinzheng and others added 18 commits September 2, 2026 11:42
**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
**Changes Made:**

- Use MutateRow instead of MutateRows for DirectRow.commit instead of
Table.MutateRows
- Added system test for DirectRow.commit because of the decoupling of
DirectRow.commit and Table.MutateRows
- Adjusted input error system test because of slight changes in error
behavior
- Adjusted unit tests for DirectRow.commit
**Changes made:**

- Refactored `_MappableAttributesMixin` to `helpers.py` for use in
`RowRange`.
- Used `RowRange` and `ReadRowsQuery` from the data client as backing
data sources for `RowRange` and `RowSet` respectively.
According to go/rst_stream, `INTERNAL` errors with error messages
related to an `rst_stream` error should be interpreted as `UNAVAILABLE`
errors instead of internal errors. This PR creates a custom retry
predicate to allow retrying of `INTERNAL` errors with rst_stream
specific error messages if the `ServiceUnavailable` exception is allowed
to be retried.

---------

Co-authored-by: Daniel Sanche <sanche@google.com>
**Changes Made:**
- Added methods to convert `Row` and `Cell` objects in the data client
to `PartialRowData` and `Cell` objects in the legacy client.
- Removed legacy client code related to processing `ReadRowResponse`
chunks and testing `ReadRowResponse` chunks.
- Removed `_update_message_request` from `RowSet` because it's no longer
needed to create a `ReadRowQuery`
- Rerouted `read_row` and `read_rows` to use their data client
counterparts in `table.py`.
@daniel-sanche
daniel-sanche force-pushed the shim/11-read-rows-data-client branch from 92da437 to e435179 Compare September 2, 2026 18:42
daniel-sanche and others added 6 commits September 2, 2026 12:06
**Changes made:**

- Refactored `_MappableAttributesMixin` to `helpers.py` for use in
`RowRange`.
- Used `RowRange` and `ReadRowsQuery` from the data client as backing
data sources for `RowRange` and `RowSet` respectively.
According to go/rst_stream, `INTERNAL` errors with error messages
related to an `rst_stream` error should be interpreted as `UNAVAILABLE`
errors instead of internal errors. This PR creates a custom retry
predicate to allow retrying of `INTERNAL` errors with rst_stream
specific error messages if the `ServiceUnavailable` exception is allowed
to be retried.

---------

Co-authored-by: Daniel Sanche <sanche@google.com>
daniel-sanche and others added 2 commits September 2, 2026 12:25
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
gkevinzheng and others added 9 commits September 2, 2026 14:58
**Changes made:**

- Refactored `_MappableAttributesMixin` to `helpers.py` for use in
`RowRange`.
- Used `RowRange` and `ReadRowsQuery` from the data client as backing
data sources for `RowRange` and `RowSet` respectively.
According to go/rst_stream, `INTERNAL` errors with error messages
related to an `rst_stream` error should be interpreted as `UNAVAILABLE`
errors instead of internal errors. This PR creates a custom retry
predicate to allow retrying of `INTERNAL` errors with rst_stream
specific error messages if the `ServiceUnavailable` exception is allowed
to be retried.

---------

Co-authored-by: Daniel Sanche <sanche@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@daniel-sanche
daniel-sanche marked this pull request as ready for review September 2, 2026 22:09
@daniel-sanche
daniel-sanche requested a review from a team as a code owner September 2, 2026 22:09

self.rows = {}
@property
def last_scanned_row_key(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this property was only used in the internal method? Would it actually be called? Is it safe to just remove it?

Same question with read_method and retry, and request

:type row_key: bytes
:param row_key: The key of the row to read from.

:type filter_: :class:`.RowFilter`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did we rewrite the RowFilter class?

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.

3 participants