# Incremental model with no data to merge

**URL:** <https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205>\
**Category:** Help\
**Tags:** incremental, snowflake\
**Created:** [October 28, 2022, 10:06pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205 "2022-10-28T22:06:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trongle](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@trongle](https://discourse.getdbt.com/u/trongle)\
**Post date:** [October 28, 2022, 10:06pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205/1 "2022-10-28T22:06:28Z")

</div>

Hi all,  
My team is using Fivetran and DBT to load/transform the data into Snowflake and we’re working on using incremental models.

What works:

- The initial load of the data works fine
- if there **IS** data to merge into Snowflake works fine

What fails:

- When there **ISN’T** any new data to merge then we get an error in Fivetran similar to below:

```nohighlight
[0m20:49:18 Database Error in model develop_test_model (models/develop/misc/develop_test_model.sql)
e[0m20:49:18 001003 (42000): SQL compilation error:
e[0m20:49:18 syntax error line 19 at position 6 unexpected ')'.

```

Looking into the Snowflake query history it eventually errors on a query like this (please ignore line positions, i removed whitespaces):

```auto
create or replace temporary table WAREHOUSE.DATABASE.develop_test_model__dbt_tmp as ( );

```

Is there a way to skip the incremental load process if there is no data to merge in?

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [November 1, 2022, 4:13am UTC](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205/2 "2022-11-01T04:13:26Z")

</div>

Can you post the code of the incremental model you’re having trouble with?

Your code needs to be valid both when `is_incremental()` is true or false - it sounds like you have your entire model logic inside an if block. You should return no rows when a model has no changes, but there should still be sql.

---

<div class="post-metadata">

**Author:** ![trongle](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@trongle](https://discourse.getdbt.com/u/trongle)\
**Post date:** [November 2, 2022, 10:11pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205/3 "2022-11-02T22:11:02Z")

</div>

you were correct. i did have everything in an if block so when it was evaluating what to put into the temporary table, there was nothing to put in there. i added an else statement that just returns 0 rows and that fixed the issue. thank you for the assistance!

---

<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:** [November 9, 2022, 10:11pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205/4 "2022-11-09T22:11:47Z")

</div>

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