我正在尝试使用 BigQuery 的 Python API 创建新表:
bigquery.tables().insert(
projectId="xxxxxxxxxxxxxx",
datasetId="xxxxxxxxxxxxxx",
body='{
"tableReference": {
"projectId":"xxxxxxxxxxxxxx",
"tableId":"xxxxxxxxxxxxxx",
"datasetId":"accesslog"},
"schema": {
"fields": [
{"type":"STRING", "name":"ip"},
{"type":"TIMESTAMP", "name":"ts"},
{"type":"STRING", "name":"event"},
{"type":"STRING", "name":"id"},
{"type":"STRING","name":"sh"},
{"type":"STRING", "name":"pub"},
{"type":"STRING", "name":"context"},
{"type":"STRING", "name":"brand"},
{"type":"STRING", "name":"product"}
]
}
}'
).execute()
我得到的错误是:
(<class 'apiclient.errors.HttpError'>, <HttpError 400 when requesting https://www.googleapis.com/bigquery/v2/projects/xxxxxxxxxxxxxx/datasets/xxxxxxxxxxxxxx/tables?alt=json returned "Required parameter is missing">, <traceback object at 0x17e1c20>)
我认为所有必需的参数都包含在https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/bigquery_v2.tables.html#insert中
少了什么东西?