Skip to content

Add 'auto-detect schema' to bigquery snippet #2148

Closed

Description

@redwrasse

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

Activity

  1. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Jul 17, 2017
  2. garrettjonesgoogle commented on Jul 17, 2017

    @garrettjonesgoogle
    Contributor
  3. lesv commented on Jul 19, 2017

    @lesv
    Contributor

    @tswast Can you do this?

  4. tswast commented on Jul 19, 2017

    @tswast
    Contributor

    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.

  5. garrettjonesgoogle commented on Aug 10, 2017

    @garrettjonesgoogle
    Contributor

    Closing this out since @tswast is tracking it on his own backlog.

  6. TJC commented on Aug 3, 2018

    @TJC

    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?

  7. tswast commented on Aug 3, 2018

    @tswast
    Contributor

    @TJC thanks for the reminder. Yeah, I'll bump the priority.

  8. TJC commented on Aug 6, 2018

    @TJC

    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)
    
  9. the-dagger commented on Oct 12, 2018

    @the-dagger

    Bumping this since it hasn't been added yet.
    cc : @tswast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions