问题
I am trying to query a dataset with multiple tables and equivalent views. I am trying to query just the tables using _table_suffix, but it returns an error "Query Failed Error: Views cannot be queried through prefix. Partial list of the matched views-......" I cannot remove the views from the dataset. Is there a way to query the tables only and ignore the views?
SELECT COUNT(*), _table_suffix, DATE(created)
FROM `dataset.viewed_*`
WHERE _table_suffix like '%_page'
回答1:
Your options are:
- Recreate the views under different names, so that the
viewed_
prefix doesn't match them. - Use a longer prefix than
viewed_
(if possible) when matching the table names, so that the view names aren't included. - Migrate your tables to a single partitioned table so that you don't need to use a wildcard.
I would suggest the third option if at all possible; using a partitioned table is much better than trying to maintain multiple tables with a common schema.
来源:https://stackoverflow.com/questions/52521822/query-failed-error-views-cannot-be-queried-through-prefix-partial-list-of-the