Ase*_*ake 4 google-apps-script google-bigquery google-sheets-api
我正在尝试使用来自 appscript 的查询字符串(附在代码中)运行 bigquery api 调用;查询在 bigquery UI 中运行良好
我尝试了以下但没有成功:
1. 在查询字符串中的 orders.creation_date 中包含括号
2. 用实际表替换订单,即 [my-project:theservices.theservice_order_item]
/**
* Runs a BigQuery query and logs the results in a spreadsheet.
*/
function runQuery() {
var projectId = 'my-project';
var request = {
query:
"SELECT extract(date from orders.creation_date) as the_date \n FROM [my-project:theservices.theservice_order_item] AS orders LIMIT 10;"
};
};
Run Code Online (Sandbox Code Playgroud)
以下是我得到的错误:
API call to bigquery.jobs.query failed with error: Encountered " "FROM" "from "" at line 1, column 22. was expected: ")" ... (line 23, file "代码”)
引用App Script BigQuery Standard SQL 插入或更新语句:
您需要将 useLegacySql 标志/参数设置为 false,以指示您要使用标准 SQL,如下所示:
var job = {
configuration: {
query: {
query: 'SELECT ....',
useLegacySql: false
}
Run Code Online (Sandbox Code Playgroud)
此外,当一个表看起来像这样时——那就是#legacySQL:
FROM [my-project:theservices.theservice_order_item]
Run Code Online (Sandbox Code Playgroud)
在#standardSQL 中,表应该用波浪号'`' 括起来并有一个'.' 项目和数据集名称之间:
FROM `my-project.theservices.theservice_order_item`
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2909 次 |
最近记录: |