问题描述
这延伸了Jordan的帖子:
以下是一个工作TABLE_QUERY SQL的示例。
SELECT count(*)
FROM TABLE_QUERY(publicdata:samples,
MSEC_TO_TIMESTAMP(creation_time)< DATE_ADD(CURRENT_TIMESTAMP(),-7 ,'DAY'))
但是,如果project_id包含一个 - 连字符,TABLE_QUERY将失败。例如:
选择任何
FROM TABLE_QUERY(other-public-data:samples,
MSEC_TO_TIMESTAMP (creation_time)< DATE_ADD(CURRENT_TIMESTAMP(),-7,'DAY'))
可能因为解释器会看到一个减法操作。
没有eval(JavaScript)或exec(Python)操作将字符串转换为变量名称,有没有任何建议如何在BigQuery中实现这一功能?
Escapewith []:
选择任何
FROM TABLE_QUERY([other-public-data:samples],
MSEC_TO_TIMESTAMP(creation_time)< DATE_ADD(CURRENT_TIMESTAMP() 7,'DAY'))
This extends Jordan's post here:How do I use the TABLE_QUERY() function in BigQuery?
Here is an example of working TABLE_QUERY SQL.
SELECT count(*)
FROM TABLE_QUERY(publicdata:samples,
"MSEC_TO_TIMESTAMP(creation_time) < DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY')")
However, TABLE_QUERY fails if the project_id contains a "-" hyphen. For example:
SELECT whatever
FROM TABLE_QUERY(other-public-data:samples,
"MSEC_TO_TIMESTAMP(creation_time) < DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY')")
Likely because the interpreter sees a subtraction operation.
Without an "eval" (JavaScript) or "exec" (Python) operation to convert strings to variable names, are there any suggestions to get this working in BigQuery?
"Escape" with []:
SELECT whatever
FROM TABLE_QUERY([other-public-data:samples],
"MSEC_TO_TIMESTAMP(creation_time) < DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY')")
这篇关于Google BigQuery:如果project_id包含连字符“ - ”,则使用TABLE_QUERY。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!