问题描述
我试图通过API将bigquery数据导出到谷歌云存储桶中。我调整了此处的代码片段
I am trying to export bigquery data to google cloud storage bucket via the API. I adapted a code snippet from herehttps://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
}
由于我的数据是嵌套的,无法导出为CSV格式,gcsUrl使用gs:// mybucket / export_ *,所以我使用JSON交换格式。 JSON。
但是,错误消息告诉我以下问题:
I have exchanged format with "JSON" since my data is nested and can't be exported to CSV and the gcsUrl with "gs://mybucket/export_*.json". But the error messages tells me the following problem:
transfer not working BigQueryError{reason=invalid, location=null, message=Operation cannot be performed on a nested schema. Field: totals}
任何建议怎么办? JSON应该能够处理一个嵌套的格式...
Any advice what to do? JSON should be able to handle a nested format...
推荐答案
参考,您应该设置NEWLINE_DELIMITED_JSON
为格式
变量,以导出为JSON。
Referring to the destinationFormat option, you should set "NEWLINE_DELIMITED_JSON"
for the format
variable in order to export as JSON.
这篇关于将嵌套的BigQuery数据导出到云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!