xneg
xneg

Reputation: 1358

How can I actually see the merge instruction for incremental models in dbt core?

According to dbt docs you just add some instruction like

{{
    config(
        materialized='incremental',
        incremental_strategy='merge',
        unique_key='date_day'
    )
}}
...
{% if is_incremental() %}
...
{% endif %}

and it will generate for you incremental model that will use merge strategy to update destination.

But if you do dbt compile --select <your_model> it will only return SELECT statement + (optionally) part inside if is_incremental(). Is it possible to do some sort of dry-run or something similar so I can see a real command that will be executed against destination? Like how I can check that unique_key or incremental_predicates are really used?

I'm using dbt core with BigQuery adapter but I assume it should work for any adapter.

Upvotes: 1

Views: 55

Answers (1)

Limonka
Limonka

Reputation: 856

Check the target/run/ folder, the code there is the actual SQL.

And yes, you can perform the dry run, there is the --empty flag to do this. Just be very careful and don't use it on production nor for models with the 'table' materialization, as it would truncate them.

Upvotes: 1

Related Questions