dataform-co / dataform

Dataform is a framework for managing SQL based data operations in BigQuery
https://cloud.google.com/dataform/docs
Apache License 2.0
851 stars 163 forks source link

Bug with SQL template variables when action inside while loop #1841

Open max-ostapenko opened 2 months ago

max-ostapenko commented 2 months ago

When iterating an operation over the months I'm using while loop and a dynamic date variable in the SQL template.

I see something strange happens to the iterator variable within the SQL template.

Example:

let i = 0;
while (i <= 1) {
    operate(`while ${i}`).queries(ctx => `
        SELECT '${i}' AS value
    `);

    i++;
}

I get the following compiled SQLs:

  1. Operation "while 0"

    SELECT '2' AS value
  2. Operation "while 1"

    SELECT '2' AS value

Originally reported here: https://issuetracker.google.com/issues/365808530