NOTE: It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio’s performance benefits, the codebase should be designed to be async from the ground up.
class google.cloud.bigtable.data._async.client.MaterializedViewAsync(client: google.cloud.bigtable.data._async.client.BigtableDataClientAsync, instance_id: str, materialized_view_id: str, app_profile_id: Optional[str] = None, **kwargs)
Provides read access to a materialized view of a table.
A materialized view is a pre-computed, read-only view over a table, defined by a SQL query. Materialized views support read operations only; mutation methods raise NotImplementedError.
MaterializedView object maintains materialized_view_id and app_profile_id context, and passes them with each call
Initialize a MaterializedView instance
Must be created within an async context (running event loop)
Parameters
instance_id – The Bigtable instance ID to associate with this client. instance_id is combined with the client’s project to fully specify the instance
materialized_view_id – The id for the materialized view to use for requests
app_profile_id – The app profile to associate with requests. https://cloud.google.com/bigtable/docs/app-profiles
default_read_rows_operation_timeout – The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes)
default_read_rows_attempt_timeout – The default timeout for individual read rows rpc requests, in seconds. If not set, defaults to 20 seconds
default_operation_timeout – The default timeout for all other operations, in seconds. If not set, defaults to 60 seconds
default_attempt_timeout – The default timeout for all other individual rpc requests, in seconds. If not set, defaults to 20 seconds
default_read_rows_retryable_errors – a list of errors that will be retried if encountered during read_rows and related operations. Defaults to 4 (DeadlineExceeded), 14 (ServiceUnavailable), and 10 (Aborted)
default_retryable_errors – a list of errors that will be retried if encountered during all other operations. Defaults to 4 (DeadlineExceeded) and 14 (ServiceUnavailable)
Raises
RuntimeError – if called outside of an async context (no running event loop)
async _aenter_()
Implement async context manager protocol
Ensure registration task has time to run, so that grpc channels will be warmed for the specified instance
async _aexit_(exc_type, exc_val, exc_tb)
Implement async context manager protocol
Unregister this instance with the client, so that grpc channels will no longer be warmed
async bulk_mutate_rows(*args, **kwargs)
Mutations are not supported for materialized views
Raises
NotImplementedError – always; materialized views are read-only
async check_and_mutate_row(*args, **kwargs)
Mutations are not supported for materialized views
Raises
NotImplementedError – always; materialized views are read-only
async close()
Called to close the Table instance and release any resources held by it.
async mutate_row(*args, **kwargs)
Mutations are not supported for materialized views
Raises
NotImplementedError – always; materialized views are read-only
mutations_batcher(*args, **kwargs)
Mutations are not supported for materialized views
Raises
NotImplementedError – always; materialized views are read-only
async read_modify_write_row(*args, **kwargs)
Mutations are not supported for materialized views
Raises
NotImplementedError – always; materialized views are read-only
async read_row(row_key: str | bytes, *, row_filter: Optional[google.cloud.bigtable.data.row_filters.RowFilter] = None, operation_timeout: float | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, attempt_timeout: float | None | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, retryable_errors: Union[Sequence[type[Exception]], google.cloud.bigtable.data._helpers.TABLE_DEFAULT] = TABLE_DEFAULT.READ_ROWS)
Read a single row from the table, based on the specified key.
Failed requests within operation_timeout will be retried based on the retryable_errors list until operation_timeout is reached.
Parameters
query – contains details about which rows to return
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to the Table’s default_read_rows_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_read_rows_attempt_timeout. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_read_rows_retryable_errors.
Returns
a Row object if the row exists, otherwise None
Return type
Row | None
Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error
async read_rows(query: google.cloud.bigtable.data.read_rows_query.ReadRowsQuery, *, operation_timeout: float | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, attempt_timeout: float | None | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, retryable_errors: Union[Sequence[type[Exception]], google.cloud.bigtable.data._helpers.TABLE_DEFAULT] = TABLE_DEFAULT.READ_ROWS)
Read a set of rows from the table, based on the specified query. Retruns results as a list of Row objects when the request is complete. For streamed results, use read_rows_stream.
Failed requests within operation_timeout will be retried based on the retryable_errors list until operation_timeout is reached.
Parameters
query – contains details about which rows to return
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to the Table’s default_read_rows_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_read_rows_attempt_timeout. If None, defaults to operation_timeout. If None, defaults to the Table’s default_read_rows_attempt_timeout, or the operation_timeout if that is also None.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_read_rows_retryable_errors.
Returns
a list of Rows returned by the query
Return type
Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error
async read_rows_sharded(sharded_query: ShardedQuery, *, operation_timeout: float | TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, attempt_timeout: float | None | TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, retryable_errors: Sequence[type[Exception]] | TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS)
Runs a sharded query in parallel, then return the results in a single list. Results will be returned in the order of the input queries.
This function is intended to be run on the results on a query.shard() call. For example:
table_shard_keys = await table.sample_row_keys()
query = ReadRowsQuery(...)
shard_queries = query.shard(table_shard_keys)
results = await table.read_rows_sharded(shard_queries)
Parameters
sharded_query – a sharded query to execute
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to the Table’s default_read_rows_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_read_rows_attempt_timeout. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_read_rows_retryable_errors.
Returns
a list of Rows returned by the query
Return type
Raises
ShardedReadRowsExceptionGroup – if any of the queries failed
ValueError – if the query_list is empty
async read_rows_stream(query: google.cloud.bigtable.data.read_rows_query.ReadRowsQuery, *, operation_timeout: float | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, attempt_timeout: float | None | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, retryable_errors: Union[Sequence[type[Exception]], google.cloud.bigtable.data._helpers.TABLE_DEFAULT] = TABLE_DEFAULT.READ_ROWS)
Read a set of rows from the table, based on the specified query. Returns an iterator to asynchronously stream back row data.
Failed requests within operation_timeout will be retried based on the retryable_errors list until operation_timeout is reached.
Parameters
query – contains details about which rows to return
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to the Table’s default_read_rows_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_read_rows_attempt_timeout. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_read_rows_retryable_errors
Returns
an asynchronous iterator that yields rows returned by the query
Return type
AsyncIterable[Row]
Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error
async row_exists(row_key: str | bytes, *, operation_timeout: float | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, attempt_timeout: float | None | google.cloud.bigtable.data._helpers.TABLE_DEFAULT = TABLE_DEFAULT.READ_ROWS, retryable_errors: Union[Sequence[type[Exception]], google.cloud.bigtable.data._helpers.TABLE_DEFAULT] = TABLE_DEFAULT.READ_ROWS)
Return a boolean indicating whether the specified row exists in the table. uses the filters: chain(limit cells per row = 1, strip value)
Parameters
row_key – the key of the row to check
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. Defaults to the Table’s default_read_rows_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_read_rows_attempt_timeout. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_read_rows_retryable_errors.
Returns
a bool indicating whether the row exists
Return type
Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error
async sample_row_keys(*, row_range: RowRange | None = None, operation_timeout: float | TABLE_DEFAULT = TABLE_DEFAULT.DEFAULT, attempt_timeout: float | None | TABLE_DEFAULT = TABLE_DEFAULT.DEFAULT, retryable_errors: Sequence[type[Exception]] | TABLE_DEFAULT = TABLE_DEFAULT.DEFAULT)
Return a set of RowKeySamples that delimit contiguous sections of the table of approximately equal size
RowKeySamples output can be used with ReadRowsQuery.shard() to create a sharded query that can be parallelized across multiple backend nodes read_rows and read_rows_stream requests will call sample_row_keys internally for this purpose when sharding is enabled
RowKeySamples is simply a type alias for list[tuple[bytes, int]]; a list of row_keys, along with offset positions in the table
Parameters
row_range – the range of rows to sample. If not provided, samples the entire table.
operation_timeout – the time budget for the entire operation, in seconds. Failed requests will be retried within the budget.i Defaults to the Table’s default_operation_timeout
attempt_timeout – the time budget for an individual network request, in seconds. If it takes longer than this time to complete, the request will be cancelled with a DeadlineExceeded exception, and a retry will be attempted. Defaults to the Table’s default_attempt_timeout. If None, defaults to operation_timeout.
retryable_errors – a list of errors that will be retried if encountered. Defaults to the Table’s default_retryable_errors.
Returns
a set of RowKeySamples the delimit contiguous sections of the table
Return type
RowKeySamples
Raises
google.api_core.exceptions.DeadlineExceeded – raised after operation timeout will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions from any retries that failed
google.api_core.exceptions.GoogleAPIError – raised if the request encounters an unrecoverable error