Skip to content

chore(deps): Update BigQuery Storage API SDK from v1beta1 to v1#27797

Open
benhxy wants to merge 1 commit into
prestodb:masterfrom
benhxy:ben/v1
Open

chore(deps): Update BigQuery Storage API SDK from v1beta1 to v1#27797
benhxy wants to merge 1 commit into
prestodb:masterfrom
benhxy:ben/v1

Conversation

@benhxy
Copy link
Copy Markdown

@benhxy benhxy commented May 14, 2026

Description

Update Google BigQuery Storage API SDK from v1beta1 to v1.

Motivation and Context

v1beta1 is a preview API, and v1 is a GA API with better performance and reliability.

Impact

There should be no visible impact as v1 API is backward compatible (no changes in API activation, IAM permission, quota, billing etc.). V1 API has been GA-ed since 2020 and most of SDK/customers have migrated to v1.

Test Plan

Updates to unit tests.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Update Google BigQuery Storage API SDK from v1beta1 to v1. 

Summary by Sourcery

Upgrade BigQuery storage integration from the v1beta1 API to the GA v1 API and align request/response handling accordingly.

Enhancements:

  • Update BigQuery Storage read session creation and read-rows helpers to use v1 request/response types and semantics.
  • Simplify table reference construction and retry offset handling to match the v1 client API.
  • Adjust tests and mock helpers to operate on v1 ReadRowsRequest/ReadRowsResponse types.

Build:

  • Switch presto-bigquery module dependency from proto-google-cloud-bigquerystorage-v1beta1 to proto-google-cloud-bigquerystorage-v1.

Summary by Sourcery

Upgrade the BigQuery connector to use the GA BigQuery Storage v1 Read API instead of the deprecated v1beta1 API for read sessions and row retrieval.

Enhancements:

  • Replace usages of BigQueryStorageClient and v1beta1 request/response types with BigQueryReadClient and v1 equivalents across split creation and page source code.
  • Simplify table and stream reference construction and offset handling to follow the v1 API model while preserving existing read and retry behavior.

Build:

  • Switch the presto-bigquery module dependency from proto-google-cloud-bigquerystorage-v1beta1 to proto-google-cloud-bigquerystorage-v1.

Tests:

  • Update BigQuery read-rows unit tests and mocking utilities to operate on v1 ReadRowsRequest/ReadRowsResponse types.

Summary by Sourcery

Upgrade the BigQuery connector to use the GA BigQuery Storage v1 Read API instead of the deprecated v1beta1 API for read sessions and row retrieval.

Enhancements:

  • Replace BigQueryStorageClient usage with BigQueryReadClient and update read session and read-rows handling to v1 request/response types.
  • Simplify table reference construction and offset handling to align with the BigQuery Storage v1 API semantics.
  • Rename and rewire the client factory and connector wiring to produce BigQueryReadClient instances across the connector.

Build:

  • Switch the presto-bigquery module dependency from proto-google-cloud-bigquerystorage-v1beta1 to proto-google-cloud-bigquerystorage-v1.

Tests:

  • Update BigQuery read-rows unit tests and mocked response helpers to operate on v1 ReadRowsRequest/ReadRowsResponse types.

Summary by Sourcery

Migrate the BigQuery connector from the preview BigQuery Storage v1beta1 client to the GA BigQuery Storage v1 Read API for creating read sessions and reading rows.

Enhancements:

  • Replace usage of BigQueryStorageClient with BigQueryReadClient across read session creation, split management, and page source implementations.
  • Adjust read session and read-rows request/response handling, including stream/table references and offset management, to match the BigQuery Storage v1 API semantics.

Build:

  • Update the presto-bigquery module dependency from proto-google-cloud-bigquerystorage-v1beta1 to proto-google-cloud-bigquerystorage-v1.

Tests:

  • Update BigQuery read-rows unit tests and mock response helpers to use BigQuery Storage v1 ReadRowsRequest/ReadRowsResponse types.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 14, 2026

Reviewer's Guide

Migrates the Presto BigQuery connector from the preview BigQuery Storage v1beta1 read API to the GA BigQuery Storage v1 Read API by swapping client factories and types, updating read session and read-rows request construction and retry logic, and aligning tests and dependencies with the new v1 protocol buffers.

Sequence diagram for BigQuery read flow using Storage v1 Read API

sequenceDiagram
    participant BigQuerySplitManager
    participant ReadSessionCreator
    participant BigQueryReadClientFactory
    participant BigQueryReadClient
    participant BigQueryResultPageSource
    participant ReadRowsHelper

    BigQuerySplitManager->>ReadSessionCreator: create(tableId, projectedColumnsNames, filter, actualParallelism)
    ReadSessionCreator->>BigQueryReadClientFactory: createBigQueryReadClient()
    BigQueryReadClientFactory-->>ReadSessionCreator: BigQueryReadClient
    ReadSessionCreator->>BigQueryReadClient: createReadSession(CreateReadSessionRequest)
    BigQueryReadClient-->>ReadSessionCreator: ReadSession

    BigQuerySplitManager-->>BigQueryResultPageSource: BigQuerySplit

    BigQueryResultPageSource->>BigQueryReadClientFactory: createBigQueryReadClient()
    BigQueryReadClientFactory-->>BigQueryResultPageSource: BigQueryReadClient
    BigQueryResultPageSource->>ReadRowsHelper: new(BigQueryReadClient, ReadRowsRequest.Builder, maxReadRowsRetries)
    BigQueryResultPageSource->>ReadRowsHelper: readRows()
    loop on retryable errors
        ReadRowsHelper->>ReadRowsHelper: request.setOffset(readRowsCount)
        ReadRowsHelper->>BigQueryReadClient: readRows(ReadRowsRequest)
        BigQueryReadClient-->>ReadRowsHelper: ReadRowsResponse
    end
Loading

File-Level Changes

Change Details Files
Replace BigQueryStorage v1beta1 client and messages with BigQuery Storage v1 BigQueryReadClient and corresponding request/response types in connector runtime code.
  • Rename and rewire BigQueryStorageClientFactory to BigQueryReadClientFactory, constructing BigQueryReadClient/BigQueryReadSettings with the existing credential and header plumbing.
  • Update BigQueryResultPageSource to use BigQueryReadClient, build v1 ReadRowsRequest via setReadStream, and consume Iterator while keeping page-building logic the same.
  • Update ReadRowsHelper to depend on BigQueryReadClient, operate on v1 ReadRowsRequest/ReadRowsResponse, and use the v1 offset field directly when retrying reads.
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryReadClientFactory.java
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryResultPageSource.java
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/ReadRowsHelper.java
Adapt read session creation and split management to the BigQuery Storage v1 ReadSession API and table/stream reference model.
  • Change ReadSessionCreator to depend on BigQueryReadClientFactory, construct a v1 ReadSession via CreateReadSessionRequest with a table resource string, DataFormat.AVRO, and TableReadOptions, and use setMaxStreamCount instead of v1beta1 sharding strategy/options.
  • Inline table reference handling by generating the v1 table resource name string instead of using TableReferenceProto.TableReference.
  • Update BigQuerySplitManager to inject BigQueryReadClientFactory and to call the updated ReadSessionCreator, preserving parallelism and stream-to-split mapping.
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/ReadSessionCreator.java
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQuerySplitManager.java
Update connector wiring and page source provider to use the new BigQueryReadClientFactory throughout the BigQuery connector.
  • Modify BigQueryPageSourceProvider to inject BigQueryReadClientFactory instead of BigQueryStorageClientFactory and pass it into BigQueryResultPageSource.
  • Update BigQueryConnectorModule Guice bindings to bind BigQueryReadClientFactory as a singleton and remove references to BigQueryStorageClientFactory.
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryPageSourceProvider.java
presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryConnectorModule.java
Migrate unit test utilities and tests from v1beta1 Storage.ReadRows* types to v1 ReadRows* types.
  • Change MockResponsesBatch to iterate over v1 ReadRowsResponse objects instead of v1beta1 Storage.ReadRowsResponse, including addResponse/next implementations.
  • Update TestReadRowsHelper to mock BigQueryReadClient, build v1 ReadRowsRequest via setReadStream, use v1 ReadRowsResponse in test batches, and assert on v1 types.
  • Adjust the internal MockReadRowsHelper subclass in tests to extend the new ReadRowsHelper signature and return Iterator.
presto-bigquery/src/test/java/com/facebook/presto/plugin/bigquery/MockResponsesBatch.java
presto-bigquery/src/test/java/com/facebook/presto/plugin/bigquery/TestReadRowsHelper.java
Switch the presto-bigquery module to depend on the GA BigQuery Storage v1 protobuf artifact instead of the deprecated v1beta1 artifact.
  • Update presto-bigquery/pom.xml to replace proto-google-cloud-bigquerystorage-v1beta1 with proto-google-cloud-bigquerystorage-v1 while leaving other dependencies unchanged.
presto-bigquery/pom.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@benhxy benhxy changed the title Update bigquerystorage v1beta1 to v1 chore(deps): Update bigquerystorage v1beta1 to v1 May 14, 2026
@benhxy benhxy marked this pull request as ready for review May 14, 2026 04:17
@benhxy benhxy requested a review from a team as a code owner May 14, 2026 04:17
@benhxy benhxy changed the title chore(deps): Update bigquerystorage v1beta1 to v1 chore(deps): Update BigQuery Storage API SDK from v1beta1 to v1 May 14, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/ReadSessionCreator.java" line_range="91-94" />
<code_context>
+                    .setDataFormat(DataFormat.AVRO)
+                    .setReadOptions(readOptions);
+
+            ReadSession readSession = bigQueryReadClient.createReadSession(
+                    CreateReadSessionRequest.newBuilder()
                             .setParent("projects/" + bigQueryClient.getProjectId())
-                            .setFormat(Storage.DataFormat.AVRO)
-                            .setRequestedStreams(parallelism)
-                            .setReadOptions(readOptions)
-                            .setTableReference(tableReference)
-                            // The BALANCED sharding strategy causes the server to
-                            // assign roughly the same number of rows to each stream.
-                            .setShardingStrategy(Storage.ShardingStrategy.BALANCED)
+                            .setReadSession(sessionBuilder)
+                            .setMaxStreamCount(parallelism)
                             .build());
</code_context>
<issue_to_address>
**issue (bug_risk):** Build the ReadSession before setting it on the CreateReadSessionRequest.

`CreateReadSessionRequest#setReadSession` takes a `ReadSession`, not a builder. Use `setReadSession(sessionBuilder.build())` so the request receives a fully constructed immutable `ReadSession`.
</issue_to_address>

### Comment 2
<location path="presto-bigquery/src/test/java/com/facebook/presto/plugin/bigquery/TestReadRowsHelper.java" line_range="73-82" />
<code_context>
     {
         Iterator<MockResponsesBatch> responses;

-        MockReadRowsHelper(BigQueryStorageClient client, Storage.ReadRowsRequest.Builder request, int maxReadRowsRetries, Iterable<MockResponsesBatch> responses)
+        MockReadRowsHelper(BigQueryReadClient client, ReadRowsRequest.Builder request, int maxReadRowsRetries, Iterable<MockResponsesBatch> responses)
         {
             super(client, request, maxReadRowsRetries);
             this.responses = responses.iterator();
         }

         @Override
-        protected Iterator<Storage.ReadRowsResponse> fetchResponses(Storage.ReadRowsRequest.Builder readRowsRequest)
+        protected Iterator<ReadRowsResponse> fetchResponses(ReadRowsRequest.Builder readRowsRequest)
         {
             return responses.next();
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen tests to assert that the ReadRowsRequest offset is updated on retries

Since ReadRowsHelper now uses the top-level v1 ReadRowsRequest offset, the existing tests that only assert aggregated row counts won’t detect regressions where the offset isn’t advanced between retries. Consider enhancing MockReadRowsHelper.fetchResponses to inspect the incoming ReadRowsRequest.Builder and assert that its offset equals the expected cumulative row count before returning the next MockResponsesBatch. This will ensure the tests cover the new retry/offset semantics rather than just the final rowCount.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 73 to +82
Iterator<MockResponsesBatch> responses;

MockReadRowsHelper(BigQueryStorageClient client, Storage.ReadRowsRequest.Builder request, int maxReadRowsRetries, Iterable<MockResponsesBatch> responses)
MockReadRowsHelper(BigQueryReadClient client, ReadRowsRequest.Builder request, int maxReadRowsRetries, Iterable<MockResponsesBatch> responses)
{
super(client, request, maxReadRowsRetries);
this.responses = responses.iterator();
}

@Override
protected Iterator<Storage.ReadRowsResponse> fetchResponses(Storage.ReadRowsRequest.Builder readRowsRequest)
protected Iterator<ReadRowsResponse> fetchResponses(ReadRowsRequest.Builder readRowsRequest)
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.

suggestion (testing): Strengthen tests to assert that the ReadRowsRequest offset is updated on retries

Since ReadRowsHelper now uses the top-level v1 ReadRowsRequest offset, the existing tests that only assert aggregated row counts won’t detect regressions where the offset isn’t advanced between retries. Consider enhancing MockReadRowsHelper.fetchResponses to inspect the incoming ReadRowsRequest.Builder and assert that its offset equals the expected cumulative row count before returning the next MockResponsesBatch. This will ensure the tests cover the new retry/offset semantics rather than just the final rowCount.

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