Search code examples
google-bigquerygoogle-query-language

Google BigQuery's WITH not compiling


I am trying to run a query with a WITH clause in BigQuery. Even trying to run a very simple one like

WITH randomquery AS (SELECT * FROM example_table)
SELECT user FROM randomquery;

results in a compilation error:

Error: Encountered " "WITH" "WITH "" at line 1, column 1. Was expecting: EOF

Even copy-pasting the example query from the documentation produces the same error. What might be the problem?


Solution

  • Did you deselect Use Legacy SQL under Show Options? CTEs are only available with BigQuery's new, more standard SQL dialect (currently in beta).