I have a simple query that runs successfully, but when I introduce a variable into the query, I am unable to save a view using that query. For example:
SELECT * FROM mytable WHERE color = 'red';
This query runs fine. Then:
DECLARE color STRING DEFAULT 'red';
SELECT * FROM mytable WHERE color = color;
This query also runs fine. Then in the BigQuery UI I click to "Save view", but I get an error saying Unexpected keyword DECLARE. Why is that?