{"record":{"id":"f2d3a3eb1b10499e","repo":"apache/beam","slug":"both-numstoragewriteapistreams-and-auto-sharding-options-are","errorCode":null,"errorMessage":"Both numStorageWriteApiStreams and auto-sharding options are set. Will default to auto-sharding. To set a fixed number of streams, do not enable auto-sharding.","messagePattern":"Both numStorageWriteApiStreams and auto-sharding options are set\\. Will default to auto-sharding\\. To set a fixed number of streams, do not enable auto-sharding\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java","lineNumber":3881,"sourceCode":"              \"Triggering frequency can be specified only when writing via FILE_LOADS or STORAGE_WRITE_API, but the method was %s.\",\n              method);\n        }\n        if (method != Method.FILE_LOADS) {\n          checkArgument(\n              getNumFileShards() == 0,\n              \"Number of file shards can be specified only when writing via FILE_LOADS, but the method was %s.\",\n              method);\n        }\n        if (method == Method.STORAGE_API_AT_LEAST_ONCE\n            && getStorageApiTriggeringFrequency(bqOptions) != null) {\n          LOG.warn(\n              \"Storage API triggering frequency option will be ignored is it can only be specified only \"\n                  + \"when writing via STORAGE_WRITE_API, but the method was {}.\",\n              method);\n        }\n        if (getAutoSharding()) {\n          if (method == Method.STORAGE_WRITE_API && getStorageApiNumStreams(bqOptions) > 0) {\n            LOG.warn(\n                \"Both numStorageWriteApiStreams and auto-sharding options are set. Will default to auto-sharding.\"\n                    + \" To set a fixed number of streams, do not enable auto-sharding.\");\n          } else if (method == Method.FILE_LOADS && getNumFileShards() > 0) {\n            LOG.warn(\n                \"Both numFileShards and auto-sharding options are set. Will default to auto-sharding.\"\n                    + \" To set a fixed number of file shards, do not enable auto-sharding.\");\n          } else if (method == Method.STORAGE_API_AT_LEAST_ONCE) {\n            LOG.warn(\n                \"The setting of auto-sharding is ignored. It is only supported when writing an\"\n                    + \" unbounded PCollection via FILE_LOADS, STREAMING_INSERTS or\"\n                    + \" STORAGE_WRITE_API, but the method was {}.\",\n                method);\n          }\n        }\n      } else { // PCollection is bounded\n        checkArgument(\n            getTriggeringFrequency() == null,\n            \"Triggering frequency is only applicable to an unbounded PCollection.\");","sourceCodeStart":3863,"sourceCodeEnd":3899,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java#L3863-L3899","documentation":"When writing via STORAGE_WRITE_API, BigQueryIO lets you either fix the number of write streams (numStorageWriteApiStreams) or let Beam auto-shard streams dynamically. Both cannot apply at once; auto-sharding wins, so the sink warns that the fixed stream count is being disregarded.","triggerScenarios":"Calling withStorageApiNumStreams(n) (or setting the numStorageWriteApiStreams option) together with withAutoSharding(true) (triggering the default auto-sharding) while method is STORAGE_WRITE_API.","commonSituations":"Copy-pasted streaming write configs where a fixed stream count was tuned earlier and auto-sharding was later enabled for elasticity, leaving the fixed count stale.","solutions":["Disable auto-sharding (remove withAutoSharding(true)) to honor the fixed stream count","Remove withStorageApiNumStreams(...) and keep auto-sharding for elastic throughput","Keep auto-sharding and accept the warning; the fixed value is simply ignored"],"exampleFix":"// before\nBigQueryIO.writeTableRows().to(table).withMethod(Method.STORAGE_WRITE_API).withAutoSharding().withStorageApiNumStreams(10)\n// after\nBigQueryIO.writeTableRows().to(table).withMethod(Method.STORAGE_WRITE_API).withStorageApiNumStreams(10) // auto-sharding removed","handlingStrategy":"validation","validationCode":"boolean conflict = autoSharding && storageApiNumStreams > 0 && method == Method.STORAGE_WRITE_API; if (conflict) { /* choose one */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one sharding strategy per write: auto-sharding OR fixed streams","Remove stale numStorageWriteApiStreams tuning after enabling auto-sharding","Document the chosen streaming-write config in pipeline READMEs"],"tags":["java","apache-beam","bigquery","configuration"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}