I am trying to run Multiple CTEs and I am getting this error that says "Resources exceeded during query execution: Not enough resources for query planning - too many subqueries or query is too complex"
I had a look at articles/solutions for this error but none of them are applicable to my code as I am not doing self-joins/creating complex recursions.
My CTEs are something like this.
WITH CTE1 AS
(
SELECT "COLS"
FROM "BLAH"
)
, CTE2 AS
(
SELECT *
FROM CTE1
)
, CTE3 AS
(
SELECT *
FROM CTE2
)
, CTE4 AS
(
SELECT *
FROM CTE3
)
, CTE5 AS
(
SELECT *
FROM CTE4
)
SELECT *
FROM CTE5
Usually around CTE4 I start to receive the error mentioned above. This code gets used in a view which is then used elsewhere in another BigQuery script.