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

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.

1 Like

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

In my case, I am reading data from oracle where month wise tables are created
e.g : tbl_name202301

I want to create incremental dbt model where it should dynamically change the model name as per the oracle table names .

Help will be appreciated.