简体   繁体   English

在 Google Apps 脚本中定义 BigQuery 表位置

[英]Define BigQuery table location in Google Apps Script

I am trying to read data form BigQuery table in Google Apps Script.我正在尝试从 Google Apps 脚本中的 BigQuery 表中读取数据。 Target table is located in EU region, but US is requested by default from script.目标表位于欧盟区域,但脚本默认请求美国。

Code代码

  var request = {
    query: 'SELECT * FROM `table-name`'
  };
  var queryResults = BigQuery.Jobs.query(request, projectId);

Error:错误:

GoogleJsonResponseException: API call to bigquery.jobs.query failed with error: Not found: Dataset <dataset-name.table-name> was not found in location US GoogleJsonResponseException:API 调用 bigquery.jobs.query 失败,出现错误:未找到:在美国位置未找到数据集 <dataset-name.table-name>

Quotes `` was a problem, table name should be without without quotes:引号``是个问题,表名应该没有引号:

 var projectId = "project_id"
 var request = {    
        query: 'SELECT * FROM data_set.table ',
      };
 var queryResults = BigQuery.Jobs.query(request, projectId);

Your query is expected to be automatically routed to where the data is, if you have the right dataset to qualify the table name, eg:如果您有合适的数据集来限定表名,您的查询应该会自动路由到数据所在的位置,例如:

SELECT * FROM `myDatasetInEu.table-name`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为从 Google Apps 脚本创建的 BigQuery 中的新表设置过期时间? - How to set expiration time for a new table in BigQuery created from Google Apps Script? 编写 Google Apps 脚本以在 BigQuery“查询执行期间超出资源”时引发错误 - Program Google Apps Script to throw error when BigQuery "Resources exceeded during query execution" 如何使用 pyhton 脚本中的 API 为 Google bigquery 表中的列设置默认值 - How to set default value for column in Google bigquery table using API from pyhton script 如何在 Google BigQuery 中创建临时表 - How to create temporary table in Google BigQuery 仅在谷歌应用程序脚本中获取请求失败 - Fetch request failing in google apps script ONLY 将表从 Google BigQuery 导出到 Google Cloud Storage 时出现权限错误 - Permissions Error Exporting a table from Google BigQuery to Google Cloud Storage Google BigQuery:创建表时将日期添加到表名 - Google BigQuery: Add date to table name when creating a table 使用 Google Apps 脚本在 Google Data Studio 上自动刷新 - Auto Refresh on Google Data Studio using Google Apps Script Google Cloud - 将 Sql Server 连接到 Google Apps 脚本 - Google Cloud - Connect Sql Server to Google Apps Script BigQuery 挑战:我们如何在 Google BigQuery 中回填具有多条记录的表? - BigQuery Challenge: How can we backfill a table with multiple records in Google BigQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM