# Incremental model runs only like "create or replace table..."

**URL:** <https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370>\
**Category:** Help\
**Tags:** incremental, databricks\
**Created:** [October 17, 2023, 11:15am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370 "2023-10-17T11:15:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![petr.ruzicka](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@petr.ruzicka](https://discourse.getdbt.com/u/petr.ruzicka)\
**Post date:** [October 17, 2023, 11:15am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/1 "2023-10-17T11:15:07Z")

</div>

# Incremental model runs only like “create or replace table…”

Hi all, I have some incremental model in dbt-databricks with mehod merge. If I run “dbt run --full-refresh --select \<table\_name\>”, then is everything OK. But when I run it like “dbt run --select \<table\_name\>”, there is no difference - it is run like full-refresh…

The main peculiarity is that my colleague, who uses everything the same way, it works for him, the problem is only with me.

## Here is my code…

```sql
{{ config(
        materialized = 'incremental',
        incremental_strategy = 'merge',
        unique_key = ['server_name','stock_date','hash_guid']
        ) }}  

    SELECT 
        hash_guid
        , MAX(stock_date) AS max_date
    FROM 
        {{ ref('table_name') }} 
    WHERE
        stock_date >= '{{full_refresh_date}}'
        AND stock_date <= '{{last_stage_date}}'
    {% if is_incremental() %} 
        AND stock_date >= DATEADD(day, -31, '{{last_stage_date}}')
    {% endif %}

```

Terminal output looks OK:  
11:12:08 1 of 1 START sql incremental model schema.table\_name [RUN]

But in Databricks it is runing like “create or replace…”  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/5/5a90f89729fe07a7552722b7ac2f3ea4830de2f7.png)

Many thanks for any reply!!

PR

---

<div class="post-metadata">

**Author:** ![aschlaegel](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@aschlaegel](https://discourse.getdbt.com/u/aschlaegel)\
**Post date:** [October 18, 2023, 2:34am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/2 "2023-10-18T02:34:56Z")

</div>

Not entirely sure here but wondering if it is a parsing issue - is it possible it is caching something with regards to the command ? Also - does your table already exist when you run it without the full-refresh switch ?

---

<div class="post-metadata">

**Author:** ![petr.ruzicka](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@petr.ruzicka](https://discourse.getdbt.com/u/petr.ruzicka)\
**Post date:** [October 18, 2023, 7:28am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/4 "2023-10-18T07:28:07Z")

</div>

Hi,

thanks for your reply.

The main issue is that the model starts without merging, even if I run it without full-refresh.

The procedure for creating a table is that I run it for the first time in full-refresh mode, then the table remains - it is not deleted. On the second run, I need to start WITHOUT full-refresh, only merge, but I always get dbt run as “crate or replace table…”

It should be like this, but in my case “dbt\_INTERNAL\_SOURCE” like …\_\_dbt\_tmp does not appear:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/4/4ecc7ce310d8c73587e8c9ef54bb4015b7710c87.png)

---

<div class="post-metadata">

**Author:** ![aschlaegel](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@aschlaegel](https://discourse.getdbt.com/u/aschlaegel)\
**Post date:** [October 18, 2023, 1:57pm UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/5 "2023-10-18T13:57:01Z")

</div>

That is a bit odd for sure - the only other thing I can think of since it works for your coworker would be to compare project.yml and make sure there is not any delta in there that would affect this table - it should not since you are explicitly setting it in config in the model which should override the project settings but it might be worth a look just to confirm you are both in alignment. There is a part of me that still feel like maybe that initial run is being cached somewhere in the manifest and just being re-executed on subsequent runs.

---

<div class="post-metadata">

**Author:** ![petr.ruzicka](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@petr.ruzicka](https://discourse.getdbt.com/u/petr.ruzicka)\
**Post date:** [October 19, 2023, 7:29am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/6 "2023-10-19T07:29:00Z")

</div>

Thank you very much for the suggestions. We will try to find out in the team.

---

<div class="post-metadata">

**Author:** ![petr.ruzicka](https://avatars.discourse-cdn.com/v4/letter/p/90ced4/32.png) [@petr.ruzicka](https://discourse.getdbt.com/u/petr.ruzicka)\
**Post date:** [October 24, 2023, 5:38am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/7 "2023-10-24T05:38:17Z")

</div>

SOLVED!

Finally, creating a new schema in the unity catalog helped.

Thx, PR.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [October 31, 2023, 5:39am UTC](https://discourse.getdbt.com/t/incremental-model-runs-only-like-create-or-replace-table/10370/8 "2023-10-31T05:39:08Z")

</div>

Closed on October 31, 2023, 5:39am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
