Bigquery multiple WITH clauses throwing error
<p>I am using BigQuery to run a query with multiple WITH clauses, as follows: </p>

<pre><code>WITH subq_L1 AS (
    SELECT
        id,
        metric,
        COUNT(DISTINCT IF(DATEDIFF(TIMESTAMP('{execution_date:s}'), TIMESTAMP(ds)) &lt; 1, ds, NULL)) AS L1
    FROM
        [xxx:yyy.zzz]
    GROUP EACH BY
        id, metric
),
subq_L7 AS (
    SELECT
        id,
        metric,
        COUNT(DISTINCT IF(DATEDIFF(TIMESTAMP('{execution_date:s}'), TIMESTAMP(ds)) &lt; 7, ds, NULL)) AS L7
    FROM
        [xxx:yyy.zzz]
    GROUP EACH BY
        id, metric
),
subq_L14 AS (
    SELECT
        id,
        metric,
        COUNT(DISTINCT IF(DATEDIFF(TIMESTAMP('{execution_date:s}'), TIMESTAMP(ds)) &lt; 14, ds, NULL)) AS L14
    FROM
        [xxx:yyy.zzz]
    GROUP EACH BY
        id, metric
)
SELECT * FROM subq_L1
UNION ALL
SELECT * FROM subq_L7
UNION ALL
SELECT * FROM subq_L14
</code></pre>

<p>The '{execution_date:s}' gets formatted by python into a date-string.</p>

<p>BigQuery keeps throwing this error:</p>

<pre><code>Encountered " "WITH" "WITH "" at line 1, column 1. Was expecting: &lt;EOF&gt;.
</code></pre>

<p>All the queries run successfully if they stand alone; it is only putting them inside the WITH clause that makes it unsuccessful. </p>

<p>Why are these not succeeding? </p>