You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "SPUERSAIYAN (via GitHub)" <gi...@apache.org> on 2026/06/02 17:07:20 UTC

[PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

SPUERSAIYAN opened a new pull request, #38777:
URL: https://github.com/apache/beam/pull/38777

   ### What changed
   
   Fixes #38770
   
   This fixes handling of `num_storage_api_streams` / `num_streams` for BigQuery Storage Write API batch writes.
   
   Previously, the Java schema transform only applied `num_streams` inside the unbounded pipeline branch, so bounded batch pipelines using the Storage Write API ignored the configured fixed stream count. This change applies `withNumStorageWriteApiStreams(...)` whenever `num_streams > 0`, while keeping triggering frequency and auto-sharding behavior limited to unbounded pipelines.
   
   ### Details
   
   * Applies fixed Storage Write API stream counts to bounded and unbounded schema transform writes.
   * Keeps `auto_sharding` as an unbounded-only option.
   * Removes outdated documentation that described `num_storage_api_streams` / `num_streams` as streaming-only.
   * Updates Java, Python, and website docs to reflect batch support.
   * Adds a bounded pipeline translation test that verifies fixed stream counts produce the expected batch redistribute step.
   
   ### Validation
   
   * `git diff --check`
   * `./gradlew.bat --no-daemon --console=plain :sdks:java:io:google-cloud-platform:spotlessCheck`
   
   ### CHANGES.md
   
   Not updated because this is a targeted behavior/documentation fix rather than a broad user-facing feature addition.
   
   ---
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
   * [x] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
   * [ ] Update `CHANGES.md` with noteworthy changes.
   * [ ] If this contribution is large, please file an Apache [[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf)](https://www.apache.org/licenses/icla.pdf).
   
   See the [[Contributor Guide](https://beam.apache.org/contribute)](https://beam.apache.org/contribute) for more tips on [[how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier)](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   
   To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
   
   ## GitHub Actions Tests Status (on master branch)
   
   [![Build python source distribution and wheels](https://github.com/apache/beam/actions/workflows/build_wheels.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/actions/workflows/python_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/actions/workflows/java_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/actions/workflows/go_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [[CI.md](https://github.com/apache/beam/blob/master/CI.md)](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [[workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md)](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #38777:
URL: https://github.com/apache/beam/pull/38777#issuecomment-4604899211

   ## Summary of Changes
   
   Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
   
   This pull request addresses an issue where batch pipelines using the BigQuery Storage Write API were unable to utilize fixed stream counts. By modifying the schema transform logic, the changes ensure that configured stream counts are respected in batch contexts, while maintaining existing auto-sharding behavior exclusively for streaming pipelines. The update also cleans up documentation and includes a validation test to ensure consistent behavior across pipeline types.
   
   ### Highlights
   
   * **BigQuery Storage Write API Support**: Enabled the use of fixed stream counts for batch pipelines using the BigQuery Storage Write API, allowing for better control over parallelism.
   * **Logic Refinement**: Restricted auto-sharding behavior to unbounded pipelines while ensuring fixed stream counts are correctly applied to both bounded and unbounded writes.
   * **Documentation Updates**: Updated Java, Python, and website documentation to clarify that fixed stream counts are supported for both batch and streaming pipelines.
   * **Testing**: Added a new bounded pipeline translation test to verify that fixed stream counts correctly trigger the expected redistribute step.
   
   <details>
   <summary><b>New Features</b></summary>
   
   🧠 You can now enable **Memory** (public preview) to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
   </details>
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   <b>Customization</b>
   
   To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   </details>
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38777:
URL: https://github.com/apache/beam/pull/38777#issuecomment-4607046267

   Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #38777:
URL: https://github.com/apache/beam/pull/38777#discussion_r3343054979


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -179,11 +179,15 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) {
       PCollection<Row> inputRows = input.getSinglePCollection();
 
       BigQueryIO.Write<Row> write = createStorageWriteApiTransform(inputRows.getSchema());
+      int numStreams = configuration.getNumStreams() == null ? 0 : configuration.getNumStreams();
+
+      if (numStreams > 0) {
+        write = write.withNumStorageWriteApiStreams(numStreams);
+      }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There are two issues with the current handling of `numStreams`:
   
   1. **Validation**: If `configuration.getNumStreams()` is negative, it is silently ignored instead of throwing an error. We should validate that it is non-negative.
   2. **Explicit Override**: If `configuration.getNumStreams()` is explicitly set to `0`, the current code does not call `write.withNumStorageWriteApiStreams(0)` because of the `numStreams > 0` check. This means if a user has a pipeline option `--numStorageWriteApiStreams` set to a non-zero value, the explicit `0` configuration in the SchemaTransform will be ignored, and the pipeline option's value will be used instead. To allow explicitly overriding pipeline options with `0` (which is a valid configuration to keep pipeline parallelism as is), we should call `write.withNumStorageWriteApiStreams(numStreams)` whenever `configuration.getNumStreams() != null`.
   
   ```java
         Integer configuredStreams = configuration.getNumStreams();
         if (configuredStreams != null) {
           if (configuredStreams < 0) {
             throw new IllegalArgumentException("numStreams must be non-negative.");
           }
           write = write.withNumStorageWriteApiStreams(configuredStreams);
         }
         int numStreams = configuredStreams == null ? 0 : configuredStreams;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "stankiewicz (via GitHub)" <gi...@apache.org>.
stankiewicz closed pull request #38777: Fix BigQuery Storage Write API stream count for batch writes
URL: https://github.com/apache/beam/pull/38777


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38777:
URL: https://github.com/apache/beam/pull/38777#issuecomment-4609285126

   Assigning reviewers:
   
   R: @tvalentyn for label python.
   R: @Abacn for label java.
   R: @Abacn for label website.
   
   
   Note: If you would like to opt out of this review, comment `assign to next reviewer`.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "SPUERSAIYAN (via GitHub)" <gi...@apache.org>.
SPUERSAIYAN commented on PR #38777:
URL: https://github.com/apache/beam/pull/38777#issuecomment-4611148033

   > 我看到还有#38776,看起来比较简单一些。
   
   Thanks for pointing this out. I understand that #38776 is another PR with a smaller change  to this issue.
   
    If #38776 already fixes the problem, I’m happy to close this PR to avoid duplicate work


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "SPUERSAIYAN (via GitHub)" <gi...@apache.org>.
SPUERSAIYAN commented on code in PR #38777:
URL: https://github.com/apache/beam/pull/38777#discussion_r3343376631


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -179,11 +179,15 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) {
       PCollection<Row> inputRows = input.getSinglePCollection();
 
       BigQueryIO.Write<Row> write = createStorageWriteApiTransform(inputRows.getSchema());
+      int numStreams = configuration.getNumStreams() == null ? 0 : configuration.getNumStreams();
+
+      if (numStreams > 0) {
+        write = write.withNumStorageWriteApiStreams(numStreams);
+      }

Review Comment:
   Thanks, fixed. The PR now rejects negative numStreams and honors explicit 0 as an override for pipeline options, with tests added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix BigQuery Storage Write API stream count for batch writes [beam]

Posted by "stankiewicz (via GitHub)" <gi...@apache.org>.
stankiewicz commented on PR #38777:
URL: https://github.com/apache/beam/pull/38777#issuecomment-4611064212

   I see there is also https://github.com/apache/beam/pull/38776 , which looks a bit simpler. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org