gemini-code-assist[bot] commented on code in PR #38776:
URL: https://github.com/apache/beam/pull/38776#discussion_r3342958855
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -179,11 +179,11 @@ 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();
Review Comment:

If `configuration.getNumStreams()` is configured with a negative value, it
will be silently ignored and treated as `0` (which enables auto-sharding if
unbounded, or default behavior if bounded). We should validate that
`numStreams` is non-negative and throw an `IllegalArgumentException` if it is
negative to prevent silent configuration errors.
```java
int numStreams = configuration.getNumStreams() == null ? 0 :
configuration.getNumStreams();
if (numStreams < 0) {
throw new IllegalArgumentException("numStreams must be non-negative,
but was: " + numStreams);
}
```
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProvider.java:
##########
@@ -197,12 +197,13 @@ public PCollectionRowTuple expand(PCollectionRowTuple
input) {
: Duration.standardSeconds(triggeringFrequency));
}
// set num streams if specified, otherwise default to autoSharding
- if (numStreams > 0) {
- write = write.withNumStorageWriteApiStreams(numStreams);
- } else if (autoSharding == null || autoSharding) {
+ if (numStreams <= 0 && (autoSharding == null || autoSharding)) {
Review Comment:

Since `numStreams` is validated to be non-negative, we can simplify
`numStreams <= 0` to `numStreams == 0` for better clarity.
```suggestion
if (numStreams == 0 && (autoSharding == null || autoSharding)) {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]