问题
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