我一直在嘗試創建一個作業到加載將Google雲端存儲中的壓縮json文件加載到Google BigQuery表格。我在Google雲端存儲和Google BigQuery中都擁有讀/寫權限。此外,上傳的文件與BigQuery相同,屬於同一個項目。將存儲在Google雲端存儲中的文件加載到Big Query中時出錯
當我通過POST請求訪問此URL https://www.googleapis.com/upload/bigquery/v2/projects/NUMERIC_ID/jobs後面的資源時,會出現問題。請求上述資源的內容可以發現如下:
{
"kind" : "bigquery#job",
"projectId" : NUMERIC_ID,
"configuration": {
"load": {
"sourceUris": ["gs://bucket_name/document.json.gz"],
"schema": {
"fields": [
{
"name": "id",
"type": "INTEGER"
},
{
"name": "date",
"type": "TIMESTAMP"
},
{
"name": "user_agent",
"type": "STRING"
},
{
"name": "queried_key",
"type": "STRING"
},
{
"name": "user_country",
"type": "STRING"
},
{
"name": "duration",
"type": "INTEGER"
},
{
"name": "target",
"type": "STRING"
}
]
},
"destinationTable": {
"datasetId": "DATASET_NAME",
"projectId": NUMERIC_ID,
"tableId": "TABLE_ID"
}
}
}
}
但是,錯誤不作任何意義,也可以在下面找到:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0: "
}
],
"code": 400,
"message": "Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0: "
}
}
我知道問題不在於項目ID或位於身份驗證頭中的訪問令牌,因爲我之前已成功創建了空表。我還指定內容類型標題爲application/json
,我認爲這不是問題,因爲主體內容應該是json編碼。
在此先感謝
該請求對我來說看起來沒問題。模式中的「目標」字段末尾會有一個額外的逗號,這可能會使API認爲您有0個作業配置。 –
謝謝,但這個逗號是一個拼寫錯誤,因爲我刪除了這個模式中的更多元素,使得問題變得更簡單。問題仍然存在。 – rubioz