Add a Java example of loading files from Cloud Storage to BigQuery with the schema not specified, eg. what is 'auto-detect schema' in the BigQuery UI. Cannot find any documentation for this or code examples by way of Google.
Current snippet example:
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets/CreateTableAndLoadData.java
cc @lesv @tswast
@tswast Can you do this?
Added to my backlog.
The gist is to set the autodetect parameter on the LoadJobConfiguration. http://googlecloudplatform.github.io/google-cloud-java/0.20.2/apidocs/index.html
P.S. The autodetect parameter is no longer "experimental" in the REST API. The JavaDocs should get updated.
Closing this out since @tswast is tracking it on his own backlog.
Hey all -- it's been about 13 months since this issue was opened -- and it's a high hit for the Google Search on how to enable autodetection. I still can't see how to do this in the example snippets, or the documentation.
Any chance of a bump on this issue?
@TJC thanks for the reminder. Yeah, I'll bump the priority.
For anyone else who is coming across this issue with the same question -- here was my solution:
val tableId = TableId.of("my_dataset", "my_table_name")
val jobBuilder = LoadJobConfiguration.newBuilder(tableId, gcsUri)
jobBuilder.setAutodetect(true)
jobBuilder.setFormatOptions(FormatOptions.json())
val loadJobCfg = jobBuilder.build()
val loadJob = JobInfo.of(loadJobCfg)
Bumping this since it hasn't been added yet.
cc : @tswast
Most helpful comment
For anyone else who is coming across this issue with the same question -- here was my solution: