Hi everyone, How to dynamically rename the table name based on data changes?

Example:
Currently we have 2020 year data so table created as xxx_2020 but later the data in the table changes and contains 2021 data then table should be renamed to xxx_2021

Table 2020 should be renamed to 2021.

In dbt, the table name is the model name. We don’t dynamically rename models. (Nor can I imagine wanting to split tables up by years!)

Can you share more about your use cases?

1 Like

It appears like you are trying to shard your data based on year. In that case you should look into table partitioning based on your datawarehouse.

1 Like