【问题标题】:How to set `ignoreUnknownValues` option to `true` in BigQuery java client load job如何在 BigQuery java 客户端加载作业中将“ignoreUnknownValues”选项设置为“true”
【发布时间】:2017-11-01 07:24:41
【问题描述】:

我有一个 Java 程序,它使用 BigQuery Java 客户端库将 JSON 数据从 Google 云存储导入 BigQuery。我正在使用Table.load() 方法来启动加载作业。对于此加载作业,如何将 ignoreUnknownValues 选项设置为 true

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    好的,这就是你的做法。

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

    【讨论】:

      【解决方案2】:

      你可以看到这个docs

      我认为您不能将此标志与“加载”一起使用,因为BigQuery.JobOption 中没有标志“ignoreUnknownValues”:

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

      但您可以尝试“插入”选项而不是“加载”:

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

      所以:

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

      【讨论】:

      • 感谢您的回复。 table.insert 对我不起作用,因为我正在从 JSON 文件导入数据。我没有将数据加载到内存中。
      • 在这种情况下你可以使用bq Command-Line Tool
      • 但我的问题是关于 java 客户端库的。
      猜你喜欢
      • 1970-01-01
      • 2015-12-28
      • 2021-12-05
      • 1970-01-01
      • 2014-11-10
      • 2014-01-04
      • 1970-01-01
      • 1970-01-01
      • 2014-09-22
      相关资源
      最近更新 更多