Read Rows Query
class google.cloud.bigtable.data.read_rows_query.ReadRowsQuery(row_keys: Optional[Union[list[str | bytes], str, bytes]] = None, row_ranges: Optional[Union[list[google.cloud.bigtable.data.read_rows_query.RowRange], google.cloud.bigtable.data.read_rows_query.RowRange]] = None, limit: Optional[int] = None, row_filter: Optional[google.cloud.bigtable.data.row_filters.RowFilter] = None)
Bases: object
Class to encapsulate details of a read row request
Create a new ReadRowsQuery
Parameters
row_keys (-) – row keys to include in the query a query can contain multiple keys, but ranges should be preferred
row_ranges (-) – ranges of rows to include in the query
limit (-) – the maximum number of rows to return. None or 0 means no limit default: None (no limit)
row_filter (-) – a RowFilter to apply to the query
_eq_(other)
RowRanges are equal if they have the same row keys, row ranges, filter and limit, or if they both represent a full scan with the same filter and limit
add_key(row_key: str | bytes)
Add a row key to this query
A query can contain multiple keys, but ranges should be preferred
Parameters
row_key (-) – a key to add to this query
Returns
- a reference to this query for chaining
Raises
- ValueError if an input is not a string** or [bytes**](https://python.readthedocs.io/en/latest/library/stdtypes.html#bytes) –
add_range(row_range: google.cloud.bigtable.data.read_rows_query.RowRange)
Add a range of row keys to this query.
Parameters
row_range (-) – a range of row keys to add to this query
shard(shard_keys: RowKeySamples)
Split this query into multiple queries that can be evenly distributed across nodes and run in parallel
Returns
- a ShardedQuery that can be used in sharded_read_rows calls
Raises
- AttributeError if the query contains a limit –
class google.cloud.bigtable.data.read_rows_query.RowRange(start_key: Optional[Union[str, bytes]] = None, end_key: Optional[Union[str, bytes]] = None, start_is_inclusive: Optional[bool] = None, end_is_inclusive: Optional[bool] = None)
Bases: object
Represents a range of keys in a ReadRowsQuery
Parameters
start_key (-) – The start key of the range. If empty, the range is unbounded on the left.
end_key (-) – The end key of the range. If empty, the range is unbounded on the right.
start_is_inclusive (-) – Whether the start key is inclusive. If None, the start key is inclusive.
end_is_inclusive (-) – Whether the end key is inclusive. If None, the end key is not inclusive.
Raises
- ValueError – if start_key is greater than end_key, or start_is_inclusive, or end_is_inclusive is set when the corresponding key is None, or start_key or end_key is not a string or bytes.
_bool_()
Empty RowRanges (representing a full table scan) are falsy, because they can be substituted with None. Non-empty RowRanges are truthy.
_str_()
Represent range as a string, e.g. “[b’a’, b’z)” Unbounded start or end keys are represented as “-inf” or “+inf”
property end_is_inclusive(: [bool](https://python.readthedocs.io/en/latest/library/functions.html#bool )
Returns whether the range is inclusive of the end key. Returns True if the range is unbounded on the right.
property end_key(: bytes | [None](https://python.readthedocs.io/en/latest/library/constants.html#None )
Returns the end key of the range. If None, the range is unbounded on the right.
property start_is_inclusive(: [bool](https://python.readthedocs.io/en/latest/library/functions.html#bool )
Returns whether the range is inclusive of the start key. Returns True if the range is unbounded on the left.
property start_key(: bytes | [None](https://python.readthedocs.io/en/latest/library/constants.html#None )
Returns the start key of the range. If None, the range is unbounded on the left.