Skip to content

fix(bigtable): add materialized view routing param to ReadRows and Sa… - #13918

Open
mutianf wants to merge 2 commits into
googleapis:mainfrom
mutianf:add-materialized-view-routing-params
Open

fix(bigtable): add materialized view routing param to ReadRows and Sa…#13918
mutianf wants to merge 2 commits into
googleapis:mainfrom
mutianf:add-materialized-view-routing-params

Conversation

@mutianf

@mutianf mutianf commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

…mpleRowKeys

ReadRows and SampleRowKeys can target a materialized view, but the client's request-params extractor only emitted table_name + app_profile_id and ignored materialized_view_name. Per the google.api.routing annotation in bigtable.proto, materialized views are instance-scoped and must route on the instance name.

Split the header composition into composeReadRequestParams (materialized-view capable) and composeWriteRequestParams (table/authorized-view only), and add NameUtil.extractInstanceNameFromMaterializedViewName.

Add HeadersTest coverage asserting the instance-name routing param for both operations, and a ReadIT integration test that reads through a materialized view.

@mutianf
mutianf requested review from a team as code owners July 28, 2026 01:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 routing read requests (ReadRows and SampleRowKeys) targeting materialized views in Cloud Bigtable. Since materialized views are instance-scoped, they route on the instance name instead of the table name. The changes introduce helper methods to extract the instance name, update the stub to handle this routing logic, and add corresponding tests. The feedback suggests omitting the app_profile_id parameter from the routing headers when it is empty to maintain consistency with write requests and avoid sending empty parameters to the server.

Comment on lines +1186 to +1192
if (!materializedViewName.isEmpty()) {
return ImmutableMap.of(
"name",
NameUtil.extractInstanceNameFromMaterializedViewName(materializedViewName),
"app_profile_id",
appProfileId);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If appProfileId is empty, ImmutableMap.of will still include it as an empty string (i.e., "app_profile_id" -> ""). In contrast, composeWriteRequestParams omits the app_profile_id key entirely when it is empty. To maintain consistency and avoid sending an empty routing parameter to the server, we should omit app_profile_id when it is empty.

Suggested change
if (!materializedViewName.isEmpty()) {
return ImmutableMap.of(
"name",
NameUtil.extractInstanceNameFromMaterializedViewName(materializedViewName),
"app_profile_id",
appProfileId);
}
if (!materializedViewName.isEmpty()) {
String instanceName =
NameUtil.extractInstanceNameFromMaterializedViewName(materializedViewName);
if (appProfileId.isEmpty()) {
return ImmutableMap.of("name", instanceName);
}
return ImmutableMap.of("name", instanceName, "app_profile_id", appProfileId);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong

@mutianf
mutianf force-pushed the add-materialized-view-routing-params branch 2 times, most recently from f9be7f9 to f4c6c3d Compare July 28, 2026 01:44
mutianf added 2 commits July 28, 2026 02:11
…mpleRowKeys

ReadRows and SampleRowKeys can target a materialized view, but the client's
request-params extractor only emitted table_name + app_profile_id and ignored
materialized_view_name. Per the google.api.routing annotation in bigtable.proto,
materialized views are instance-scoped and must route on the instance name.

Split the header composition into composeReadRequestParams (materialized-view
capable) and composeWriteRequestParams (table/authorized-view only), and add
NameUtil.extractInstanceNameFromMaterializedViewName.

Add HeadersTest coverage asserting the instance-name routing param for both
operations, and a ReadIT integration test that reads through a materialized view.
@mutianf
mutianf force-pushed the add-materialized-view-routing-params branch from f4c6c3d to eda51af Compare July 28, 2026 02:13
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.

1 participant