How does Looker order expressions within a with clause?

I have a cascaded derived table with unions in it, something like:

derived_table: {

    sql:
      select * from ${view_1.SQL_TABLE_NAME} union
      select * from ${view_2.SQL_TABLE_NAME} union
      select * from ${view_3.SQL_TABLE_NAME}

}

And one or more of the views are dependent on other views (in some cases themselves unions). This works fine - the Looker SQL is created, the with clause does not have any forward references.

However, when I add parameters for the derived table, such as:

derived_table: {

    distribution_style: all
    sortkeys: ["trade_date"]
    sql_trigger_value: select 1 ;;

    sql:
      select * from ${view_1.SQL_TABLE_NAME} union
      select * from ${view_2.SQL_TABLE_NAME} union
      select * from ${view_3.SQL_TABLE_NAME}

}

I see the generated SQL for the CREATE TABLE is not the same and includes forward references that breaks the execution. Why is this happening? What am I missing?