Add column in the middle of the bigquery table with dbt

82 Views Asked by At

I'm a beginner in dbt-bigquery, and my client wants me to create a macro to add one or more columns to the middle of the table in bigquery. The table is partitioned and incremental with insert-overwrite mode, I defined in the configuration a contract enforced at True and with the on_schema_change parameter at syc_all_columns. I tested this with a basic test, I added a new column (A) in the middle in my source table (which i created in seeds) with a partition, and when i run my model the column (A) was added at the end of the target table, then i added another column (B) and it was added at the end when i run my model. But when i deleted one of these two columns (column B) and added it again (In 2 separate runs), the schema was finally applied in the same order as specified in my template configuration, the columns A and B added in the middle of my target table. Can anyone explain what happened or if i can expand on this process in the macros?

0

There are 0 best solutions below