feat: support row_range in sample_row_keys method#17330
Open
anvitTawar wants to merge 6 commits into
Open
Conversation
- In Table.sample_row_keys, updated the docstring to clarify that the end key of the provided row range is always returned as the last sample (or empty string if no range is specified), and updated the offset_bytes description to specify it includes preceding rows but after the last sample before the range. - In async and sync unit tests, updated the mocked SampleRowKeys stream responses to use realistic keys falling inside the RowRange bounds (e.g. b"a_key1" and b"b"), and updated the key/length assertions accordingly. - Reverted manual GAPIC type patches to let OwlBot/Librarian auto-patching handle the API class fields natively upon proto submission. TAG=agy CONV=6cea44b5-6adb-45c6-b8c8-58b37f95584c
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for a row_range parameter in the sample_row_keys method across the asynchronous, synchronous autogenerated, and legacy Bigtable clients, allowing users to restrict sampled row keys to a specific range. It also updates the test proxy handlers and adds corresponding unit tests. The review feedback highlights a potential bug in client_handler_legacy.py where an empty byte string b"" could be incorrectly treated as falsy when resolving range keys. Additionally, it suggests encapsulating None checks within helper functions and using explicit is not None checks instead of truthiness checks for optional parameters.
mutianf
approved these changes
Jun 2, 2026
mutianf
reviewed
Jun 2, 2026
Reverts the recently implemented row_range support from the legacy client code to keep it scoped cleanly to modern clients only: - Reverted Table.sample_row_keys signature, docstrings, and implementation in google/cloud/bigtable/table.py. - Reverted row_range parameter parsing in legacy test proxy client handler. - Removed unit test test_table_sample_row_keys_w_row_range in tests/unit/v2_client/test_table.py. TAG=agy CONV=6cea44b5-6adb-45c6-b8c8-58b37f95584c
d6fe742 to
ce74362
Compare
Updates the row_range check in both async and sync clients to use an explicit `is not None` check rather than truthiness evaluation. TAG=agy CONV=6cea44b5-6adb-45c6-b8c8-58b37f95584c
Restores packages/google-cloud-bigtable/google/cloud/bigtable/table.py and packages/google-cloud-bigtable/tests/unit/v2_client/test_table.py back to their original main branch states to eliminate redundant diffs from the PR. TAG=agy CONV=6cea44b5-6adb-45c6-b8c8-58b37f95584c
d5d20f8 to
f1fd7a2
Compare
Applies `ruff format` using matching version 0.14.14 to resolve style failures on the PR, ensuring only minimal necessary style corrections are made. TAG=agy CONV=6cea44b5-6adb-45c6-b8c8-58b37f95584c
f1fd7a2 to
bcada0e
Compare
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.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #17329