Analytics Engineering, Bigquery, Sql, Data Engineering, Editors Pick.
Rewrite it using your favorite dbt-like tool. (I voluntarily did not use dbt here to keep this blog post accessible to most.) Try to write this in a fully generic way: The query should work with any number of columns in the input tables and keep working even if we add a new column in the input