繁体   English   中英

将嵌套的BigQuery数据导出到云存储

[英]Export nested BigQuery data to cloud storage

我试图通过API将bigquery数据导出到谷歌云存储桶。 我从这里改编了代码片段https://cloud.google.com/bigquery/docs/exporting-data

Job job = table.extract(format, gcsUrl);
// Wait for the job to complete
try {
  Job completedJob = job.waitFor(WaitForOption.checkEvery(1, 
TimeUnit.SECONDS),
      WaitForOption.timeout(3, TimeUnit.MINUTES));
  if (completedJob != null && completedJob.getStatus().getError() == null) {
    // Job completed successfully
  } else {
    // Handle error case
       System.out.println(completedJob.getStatus().getError());
  }
} catch (InterruptedException | TimeoutException e) {
  // Handle interrupted wait

}

我已经用“JSON”交换格式,因为我的数据是嵌套的,无法导出到CSV和gcsUrl与“gs://mybucket/export_*.json”。 但错误消息告诉我以下问题:

transfer not working  BigQueryError{reason=invalid, location=null, message=Operation cannot be performed on a nested schema. Field: totals}

有什么建议吗? JSON应该能够处理嵌套格式......

引用destinationFormat选项 ,您应该为format变量设置"NEWLINE_DELIMITED_JSON" ,以便导出为JSON。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM