Hi, I have some models created as:
Select “XX”
UNION
Select “YY”
They basically works as config tables. I only want to run these models once, since I dont need to update them once they are created. How could I achieve this? Is there any config to incremental tables I should apply?
PD: option B would be to use seeds.
First off, if you don’t actually need to access any of the data stored in this config outside of dbt, you could use project variables or even an ephemeral model. I’m guessing it is a requirement to see this config in the database outside of dbt though but thought I’d mention them anyhow. When it comes to making a static table though I use an incremental model with an append strategy with an if is_incremental()
block that simply does a select * where false
. Note that the model will still re-run and re-create the table when --full-refresh
is specified but I use this as a way to actually refresh the table if there have been changes made to it. If you don’t want even a full refresh to change it, you can add a model config +full_refresh: false
that will stop it from ever being re-written and in that case you would have to drop the table manually for dbt to recreate it.
Note: @Mark Estey
originally posted this reply in Slack. It might not have transferred perfectly.
1 Like
Hi @pablote16 !
An alternative could be to:
- Materialize them as tables.
- After a build, exclude them from running using node selection methods. One of the simplest ways is to put those models in a folder and filter them by path. Another alternative if they are more scattered is to create a tag and exclude it from all jobs.
Let me know if you find it useful and if you need further clarification.
1 Like
But in that case, dbt still runs the query before checking the if is_incremental right? Is not that unperformant? In this case we are talking about simple logic tables but what about more complex models?
Super clear about the rest, thanks!