在BigQuery文档中,它表示tables.insert创建一个新的空表(https://cloud.google.com/bigquery/docs/reference/v2/tables/insert)
但是当我尝试在页面中测试该端点时,我得到404 Table not found错误。
请求
POST https://www.googleapis.com/bigquery/v2/projects/myProject/datasets/temp/tables?key={YOUR_API_KEY}
{
"expirationTime": "1452627594",
"tableReference": {
"tableId": "myTable"
}
}
响应:
404 OK
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not found: Table myProject.myTable"
}
],
"code": 404,
"message": "Not found: Table myProject:temp.myTable"
}
}
我确信404错误有一个合理的解释但我无法理解,因为我正在尝试创建该表,如果不存在它应该没问题呢?
谢谢
答案 0 :(得分:2)
您在Request Body中提供的信息不足以让BigQuery创建新表
至少 - 添加架构 - 如下所示(仅作为示例):
{
"schema": {
"fields": [
{
"name": "page_event",
"mode": "repeated",
"type": "RECORD",
"fields": [
{
"name": "id",
"type": "STRING"
},
{
"name": "description",
"type": "STRING"
}
]
}
]
}
}
在Tables resource中了解您可以在请求正文中提供的内容
以下是上述虚拟架构的示例:
POST https://www.googleapis.com/bigquery/v2/projects/myProject/datasets/temp/tables?key={YOUR_API_KEY}
{
"schema": {
"fields": [
{
"name": "page_event",
"mode": "repeated",
"type": "RECORD",
"fields": [
{
"name": "id",
"type": "STRING"
},
{
"name": "description",
"type": "STRING"
}
]
}
]
},
"expirationTime": "1452560523000",
"tableReference": {
"tableId": "myTable"
}
}
编辑:
而且你的问题中没有与"expirationTime": "1452627594"
合作的原因是因为它指向了过去