# Incremental model with no new data

**URL:** <https://discourse.getdbt.com/t/incremental-model-with-no-new-data/17741>\
**Category:** Help\
**Tags:** incremental, bigquery, dbt-core\
**Created:** [January 16, 2025, 11:09am UTC](https://discourse.getdbt.com/t/incremental-model-with-no-new-data/17741 "2025-01-16T11:09:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinK](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@MartinK](https://discourse.getdbt.com/u/MartinK)\
**Post date:** [January 16, 2025, 11:09am UTC](https://discourse.getdbt.com/t/incremental-model-with-no-new-data/17741/1 "2025-01-16T11:09:01Z")

</div>

## The problem I’m having

I have the same problem, which is described here:

> [@Incremental model with no data to merge](https://discourse.getdbt.com/t/incremental-model-with-no-data-to-merge/5205):
>
> 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: [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:…

but, I don’t know how to solve this, the solution description is too brief.

Full-refresh of the model and incremental run with new data works fine, but incremental run without new data returns error:  
Syntax error: Expected “)” but got keyword AND at [26:5]

## My model properties

```auto
{{
    config(
        materialized='incremental',
        unique_key='event_natural_key',
        partition_by = {
                'field': 'event_ts',
                'data_type': 'timestamp',
                "granularity": 'day'
                },
        upsert_date_key='start_tstamp',
        sort='start_tstamp',
        dist='event_id',
        snowplow_optimize=true,
        tags=['snowplow_unified_incremental'],
        on_schema_change='sync_all_columns'
    ) 
}}

with base as (

    select * from {{ ref('snowplow_unified','snowplow_unified_base_events_this_run') }}

    {% if is_incremental() %}
  
    and collector_tstamp > (select coalesce(max(event_collector_ts), timestamp('2000-01-01')) from {{ this }})

    {% endif %}

), 

```

---

<div class="post-metadata">

**Author:** ![MartinK](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@MartinK](https://discourse.getdbt.com/u/MartinK)\
**Post date:** [January 21, 2025, 1:26pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-new-data/17741/2 "2025-01-21T13:26:01Z")

</div>

Solved:  
` where collector_tstamp > (select coalesce(max(event_collector_ts), timestamp('2000-01-01')) from {{ this }})`

---

<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:** [January 28, 2025, 1:26pm UTC](https://discourse.getdbt.com/t/incremental-model-with-no-new-data/17741/3 "2025-01-28T13:26:32Z")

</div>

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