feat: support row_range in sample_row_keys method#17330
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
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.
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
|
Thanks for putting this together
|
Done.
The tests were failing because the API proto change used by this feature wasn't published yet. Now that that's live, the tests have all passed. |
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