[英]How to export data from BigQuery and store it as .csv in Google Storage
[英]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.