Skip to content

Commit 2c3c213

Browse files
axyjoparthea
andauthored
feat(bigtable): support materialized views in the data client (#17676)
## Summary Adds materialized view support to the Bigtable data client, alongside the existing `Table` and `AuthorizedView` surfaces: - New `MaterializedView` / `MaterializedViewAsync` classes (subclasses of `_DataApiTarget`) and a `client.get_materialized_view(instance_id, materialized_view_id)` factory. Reads (`read_rows*`, `sample_row_keys`, `row_exists`) route requests via the `materialized_view_name` field. - Materialized views are read-only in the Bigtable API — the mutation RPCs have no `materialized_view_name` field — so `mutate_row`, `bulk_mutate_rows`, `check_and_mutate_row`, `read_modify_write_row`, and `mutations_batcher` are overridden to raise `NotImplementedError` immediately instead of failing with an opaque proto error (or, for the batcher, failing later in a background flush). - Since materialized views are instance-scoped and have no backing table, table identity (`table_id`/`table_name`) moves from the shared `_DataApiTarget` base class into the `Table` and `AuthorizedView` subclasses. Public constructor signatures are unchanged. - Sync surfaces regenerated via `nox -s generate_sync`; docs pages added for both new classes. ## Test plan - [x] Unit tests: new `TestMaterializedView` suites (async + generated sync) cover construction, routing metadata (`name=<instance path>` header), factory passthrough, context-manager use, and the mutation-method rejection; `get_materialized_view` added to the existing API-surface parametrizations - [x] Full `tests/unit` suite passes locally (5394 passed) - [x] Manually exercised against a local gRPC server: `ReadRows`/`SampleRowKeys` requests carry `materialized_view_name` (not `table_name`), rows are returned through the public API, and `Table`/`AuthorizedView` behavior is unchanged - [ ] CI (docs build, lint, sync-up-to-date check across supported Python versions) --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 1ef0340 commit 2c3c213

8 files changed

Lines changed: 941 additions & 60 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Materialized View Async
2+
~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
.. note::
5+
6+
It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio's
7+
performance benefits, the codebase should be designed to be async from the ground up.
8+
9+
.. autoclass:: google.cloud.bigtable.data._async.client.MaterializedViewAsync
10+
:members:
11+
:inherited-members:

packages/google-cloud-bigtable/docs/data_client/data_client_usage.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Sync Surface
1010
sync_data_client
1111
sync_data_table
1212
sync_data_authorized_view
13+
sync_data_materialized_view
1314
sync_data_mutations_batcher
1415
sync_data_execute_query_iterator
1516

@@ -22,6 +23,7 @@ Async Surface
2223
async_data_client
2324
async_data_table
2425
async_data_authorized_view
26+
async_data_materialized_view
2527
async_data_mutations_batcher
2628
async_data_execute_query_iterator
2729

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Materialized View
2+
~~~~~~~~~~~~~~~~~
3+
4+
.. autoclass:: google.cloud.bigtable.data._sync_autogen.client.MaterializedView
5+
:members:
6+
:inherited-members:

packages/google-cloud-bigtable/google/cloud/bigtable/data/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from google.cloud.bigtable.data._async.client import (
2020
AuthorizedViewAsync,
2121
BigtableDataClientAsync,
22+
MaterializedViewAsync,
2223
TableAsync,
2324
)
2425
from google.cloud.bigtable.data._async.mutations_batcher import MutationsBatcherAsync
@@ -33,6 +34,7 @@
3334
from google.cloud.bigtable.data._sync_autogen.client import (
3435
AuthorizedView,
3536
BigtableDataClient,
37+
MaterializedView,
3638
Table,
3739
)
3840
from google.cloud.bigtable.data._sync_autogen.mutations_batcher import MutationsBatcher
@@ -80,10 +82,12 @@
8082
"BigtableDataClientAsync",
8183
"TableAsync",
8284
"AuthorizedViewAsync",
85+
"MaterializedViewAsync",
8386
"MutationsBatcherAsync",
8487
"BigtableDataClient",
8588
"Table",
8689
"AuthorizedView",
90+
"MaterializedView",
8791
"MutationsBatcher",
8892
"RowKeySamples",
8993
"ReadRowsQuery",

0 commit comments

Comments
 (0)