本文介绍了语法错误:[1:244]处出现意外的字符串文字'93868086.ga_sessions_'-BigQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用标准SQL和旧版SQL编写了此查询,但是我不断遇到不同的错误,从语法错误到无法找到表.我已经在Tableau的自定义SQL数据连接器和Web UI中进行了尝试,并得到了相同的语法错误.我正在尝试查询一年的Google Analytics(分析)表,但对于标准SQL却收到这样的错误:

I have written this query in both standard and legacy SQL but I keep getting different errors ranging from Syntax Error or that it can't even find the table. I have tried this in Tableau's Custom SQL data connector and the Web UI and get the same syntax error. I am trying to query a year's worth of Google Analytics tables, but am getting an error like this for standard SQL:

Syntax error: Unexpected string literal '93868086.ga_sessions_*' at [1:244]

我不太关心旧版SQL,因为我认为我要查询的表不喜欢它.我只是感到困惑,为什么当通用语法将表添加为字符串时,为什么它不期望字符串.难道我做错了什么?我通常使用Legacy SQL编写,因此,如果我遗漏了某些东西,我不会感到惊讶.任何帮助将不胜感激.

I am not too concerned about the Legacy SQL because I think the tables I am trying to query doesn't like it. I am just confused why it doesn't expect a string when common syntax is to add the table as a string. Am I doing something wrong? I usually write in Legacy SQL so I wouldn't be surprised if I am missing something. Any help would be appreciated.

标准SQL:

SELECT 
date,
channelGrouping,
geoNetwork.networkLocation,
device.browserVersion,
hits.dataSource,
device,
hits.page,
SUM(totals.timeOnSite),
SUM(totals.visits),
SUM(totals.bounces)
FROM
'93868086.ga_sessions_*'
WHERE
_TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY))
AND
FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY))
GROUP BY date
ORDER BY
date ASC

推荐答案

如果BigQuery标准SQL不符合[A-Za-z_][A-Za-z_0-9]* regex
,则需要对表名进行反引号因此,您需要使用

BigQuery Standard SQL requires backticks around the table name if it is not conform to [A-Za-z_][A-Za-z_0-9]* regex
So, you need to use like below

FROM `93868086.ga_sessions_*`

这篇关于语法错误:[1:244]处出现意外的字符串文字'93868086.ga_sessions_'-BigQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 01:56