这延伸了Jordan的帖子: 如何在BigQuery中使用TABLE_QUERY()函数?
以下是一个工作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
发布评论