Skip to content

feat: support row_range in sample_row_keys method#17330

Open
anvitTawar wants to merge 6 commits into
googleapis:mainfrom
anvitTawar:sample-row-keys-row-range
Open

feat: support row_range in sample_row_keys method#17330
anvitTawar wants to merge 6 commits into
googleapis:mainfrom
anvitTawar:sample-row-keys-row-range

Conversation

@anvitTawar
Copy link
Copy Markdown

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #17329

- 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
@anvitTawar anvitTawar requested a review from a team as a code owner June 1, 2026 21:43
Copy link
Copy Markdown
Contributor

@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 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.

Comment thread packages/google-cloud-bigtable/test_proxy/handlers/client_handler_legacy.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_sync_autogen/client.py Outdated
@anvitTawar anvitTawar changed the title Sample row keys row range feat: support row_range in sample_row_keys method Jun 1, 2026
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/table.py Outdated
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
@anvitTawar anvitTawar force-pushed the sample-row-keys-row-range branch from d6fe742 to ce74362 Compare June 2, 2026 18:12
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
@anvitTawar anvitTawar force-pushed the sample-row-keys-row-range branch from d5d20f8 to f1fd7a2 Compare June 2, 2026 19:40
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
@anvitTawar anvitTawar force-pushed the sample-row-keys-row-range branch from f1fd7a2 to bcada0e Compare June 2, 2026 19:44
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.

Implement specifying a row_range for sample_row_keys()

2 participants