0
votes

I have a java program that uses BigQuery Java client library to import JSON data from Google cloud storage into BigQuery. I am using Table.load() method to start the load job. How do I set the ignoreUnknownValues option to true for this load job?

2

2 Answers

1
votes

Alright so here is how you do it.

val jobConf = LoadJobConfiguration
  .newBuilder(table.getTableId, path)
  .setIgnoreUnknownValues(true)
  .setFormatOptions(FormatOptions.json())
  .build()
val loadJob = bigQuery.create(JobInfo.newBuilder(jobConf).build())
0
votes

You can see this docs

I think you cant use this flag with "load" because there are no flag "ignoreUnknownValues" into BigQuery.JobOption:

public Job load(FormatOptions format,
            String sourceUri,
            BigQuery.JobOption... options)
     throws BigQueryException

But you can try "insert" option instead "load":

public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows,
                            boolean skipInvalidRows,
                            boolean ignoreUnknownValues)
                     throws BigQueryException

so:

response = table.insert(rows, true, true);