首页 > 解决方案 > 使用 bigQuery.jobs.insert API 时如何设置查询位置

问题描述

我正在使用 bigQuery.jobs.insert API,我需要设置查询的位置

在 bigQuery.jobs.query API中,我看到我可以将位置设置如下


curl --request POST \
  'https://www.googleapis.com/bigquery/v2/projects/[PROJECTID]/queries' \
  --header 'Authorization: Bearer [YOUR_BEARER_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"query":"select 5","location":"asia-northeast1"}' \
  --compressed

但在 bigQuery.jobs.insert 我看不到这样的选项,我试过这个:

"resource": {
    "projectId": "project",
    "configuration": {
      "query": {
        "query": "SELECT 5",
        "useLegacySql": false,
        "location": "asia-northeast1",
        "defaultDataset": {
          "datasetId": "ds"
        },
        "jobReference": {
           "location": "asia-northeast1"
        }
      }
    }
  }

标签: google-bigquery

解决方案


阅读https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs

https://cloud.google.com/bigquery/docs/locations#specifying_your_location

使用 API 时,请在作业资源部分的location属性中指定您的区域。jobReference


推荐阅读