google-bigquery - BigQuery table.insert 404 错误

标签 google-bigquery

在 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 错误有一个合理的解释,但我无法理解它,因为我正在尝试创建该表,如果还不存在应该可以吗?

谢谢

最佳答案

您在请求正文中提供的信息不足以让 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"
 }
}

EDIT:

它不能与您的问题中的 "expirationTime": "1452627594" 一起使用的原因是因为它指向过去

关于google-bigquery - BigQuery table.insert 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34730159/

相关文章:

regex - BigQuery REGEXP_EXTRACT 返回 null

javascript - 为循环中的所有标记添加标记监听器

python-3.x - 无法在 BigQuery 中使用 DML 语句在作业中设置目标表

google-bigquery - 在 Google BigQuery 中创建一列 UUID

google-bigquery - 如何使用 Airflow 的 BigQuery 运算符引用外部 SQL 文件?

google-bigquery - 创建一个包含两列类型 RECORD 的表

json - 从 biq 查询命令行加载一个 json 文件

python - 高效地将 Pandas 数据框写入 Google BigQuery

ubuntu - 安装 BigQuery

python - BigQuery : Load from CSV, 跳过列