BigQueryIO - Must specify numFileShards when using FILE_LOADS with unbounded PCollection
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 205
Description
Since Beam v2.2 it's possible to use [FILE_LOADS](https://beam.apache.org/documentation/sdks/javadoc/2.2.0/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.Write.Method.html#FILE_LOADS). The documentation states that we have to specify _withTriggeringFrequency_ when using it, but doesn't talk about _withNumFileShards_, whereas if we don't specify it we get the below exception:
```
Exception in thread "main" java.lang.IllegalArgumentException
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expandTriggered(BatchLoads.java:209)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:546)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:79)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:472)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:286)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expandTyped(BigQueryIO.java:1550)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:1497)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:980)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:491)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:299)
at com.travelaudience.data.job.rtbtobigquery.Main$.main(Main.scala:74)
at com.travelaudience.data.job.rtbtobigquery.Main.main(Main.scala)
```
Either default _numFileShards_ should be used or it should be precised in the documentation that this has to be set.
Imported from Jira [BEAM-3766](https://issues.apache.org/jira/browse/BEAM-3766). Original Jira may contain additional context.
Reported by: benjben.
Contributor guide
Research direction
Start with the FILE_LOADS documentation for BigQueryIO.Write.Method and the BatchLoads.expandTriggered check shown in the stack trace; compare it with BigQueryIO.java's write configuration. Done means the documentation clearly states whether withNumFileShards is required for unbounded FILE_LOADS inputs or a default is supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, java
- Domain
- data, databases
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100