【发布时间】:2014-07-09 03:02:40
【问题描述】:
我一直在尝试创建一个作业以将压缩的 json 文件从 Google Cloud Storage 加载到 Google BigQuery 表。我在 Google Cloud Storage 和 Google BigQuery 中都有读/写权限。此外,上传的文件与 BigQuery 属于同一项目。
当我通过 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 或放置在身份验证标头中的访问令牌,因为我之前已经成功创建了一个空表。此外,我将 content-type 标头指定为 application/json,我认为这不是问题所在,因为正文内容应该是 json 编码的。
提前致谢
【问题讨论】:
-
我觉得这个请求没问题。架构中“目标”字段的末尾有一个额外的逗号,这可能会使 API 认为您有 0 个作业配置。
-
谢谢,但是那个逗号是一个错字,因为我删除了架构中的更多元素,以使问题的正文更简单。问题依然存在。
标签: google-bigquery