Google BigQuery: Using TABLE_QUERY if project_id contains a hyphen “-”

孤街醉人 提交于 2019-12-10 18:08:39

问题


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?


回答1:


"Escape" with []:

SELECT whatever
FROM TABLE_QUERY([other-public-data:samples],
  "MSEC_TO_TIMESTAMP(creation_time) < DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY')")


来源:https://stackoverflow.com/questions/35787279/google-bigquery-using-table-query-if-project-id-contains-a-hyphen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!