我正在尝试获取Apps脚本以进行BQ查询,但是出现以下错误:
在第1行第41列遇到““ FROM”“ FROM”“。期望:”)“ ...(第14行,文件“代码”)
查询在BQ中工作正常,所以我不明白这里出了什么问题...
这是脚本:
var datasets = [
['012345', "Country"]
// other datasets will complete the list
]
datasets.forEach(function(value) {
var datasetId = value[0];
var countryName = value[1];
var queryDataset = BigQuery.Jobs.query(
{'query' : 'SELECT "' + countryName + '" as country,' +
'EXTRACT(HOUR FROM TIMESTAMP_SECONDS(visitStartTime) AT TIME ZONE "Europe/Paris") AS Hour,' +
'(SELECT MAX(sourcePropertyInfo.sourcePropertyDisplayName)' +
'FROM UNNEST(session.hits) AS hits) AS service,' +
'IFNULL(SUM(totals.visits),0) as sessions,' +
'IFNULL(SUM(totals.transactions),0) as transactions,' +
'IFNULL(ROUND((SUM(totals.transactions)/SUM(totals.visits))*100,2),0) AS conversionRate' +
'FROM `xx-135923.' + datasetId + '.ga_realtime_view` AS session' +
'GROUP BY' +
'Hour,' +
'service' +
'ORDER BY' +
'Hour;',
'defaultDataset' : {
'datasetId': datasetId,
'useLegacySql' : false
}
}, 'xx-135923');
你们有什么主意吗?
感谢您的帮助
答案 0 :(得分:1)
问题解决了:这是一个愚蠢的错误。我将“'useLegacySql':false”部分放置在“ defaultDataset”对象中。所以我实际上是在Legacy SQL中查询的,而不是Standard