# custom Incremental strategies

**URL:** <https://discourse.getdbt.com/t/custom-incremental-strategies/11825>\
**Category:** Help\
**Tags:** incremental, best-practice, macros, dbt-core\
**Created:** [January 31, 2024, 3:24am UTC](https://discourse.getdbt.com/t/custom-incremental-strategies/11825 "2024-01-31T03:24:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mali](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mali](https://discourse.getdbt.com/u/Mali)\
**Post date:** [January 31, 2024, 3:24am UTC](https://discourse.getdbt.com/t/custom-incremental-strategies/11825/1 "2024-01-31T03:24:27Z")

</div>

## The problem I’m having

I’ve created a macro to have a custom Incremental Merge and call it **get\_incremental\_merge\_conditional\_sql**

Then call this Macro in my models by this config setting:

```auto
{{config(
 materialized='incremental',
 incremental_strategy='merge_conditional',
 unique_key = ['order_id','status'],
 predicates = ['DBT_INTERNAL_SOURCE.status_datetime_nzt > DBT_INTERNAL_DEST.status_datetime_nzt'],
 update_date_column = ['status_datetime_nzt'],
 tags=["magento"]
 )}}

```

When I run my model return this error:

```auto
Invalid incremental strategy provided: merge_conditional
      Expected one of: 'merge', 'replace_where', 'append', 'insert_overwrite'

```

looks Models can not find this new Macro…  
I’ve used this document to create a new Incremental macro:

> **[Configure incremental models | dbt Developer Hub](https://docs.getdbt.com/docs/build/incremental-models#custom-strategies)**
>
> Learn how to configure and optimize incremental models when developing in dbt.

Do I need to do more settings, please help

Thanks  
Mali

## The context of why I’m trying to do this

## What I’ve already tried

## Some example code or error messages

```auto
Put code inside backticks
  to preserve indentation
    which is especially important 
      for Python and YAML! 

```

---

<div class="post-metadata">

**Author:** ![DrewH](https://avatars.discourse-cdn.com/v4/letter/d/c5a1d2/32.png) [@DrewH](https://discourse.getdbt.com/u/DrewH)\
**Post date:** [February 12, 2024, 5:52pm UTC](https://discourse.getdbt.com/t/custom-incremental-strategies/11825/2 "2024-02-12T17:52:51Z")

</div>

I’m also encountering this issue on dbt 1.7 and the bigquery adapter. Did you ever find a solution? I’m putting my custom incremental strategy in `./macros` and I have many other macros that successfully run from that directory.

---

<div class="post-metadata">

**Author:** ![trouze](https://avatars.discourse-cdn.com/v4/letter/t/ccd318/32.png) [@trouze](https://discourse.getdbt.com/u/trouze)\
**Post date:** [March 15, 2024, 4:07pm UTC](https://discourse.getdbt.com/t/custom-incremental-strategies/11825/3 "2024-03-15T16:07:23Z")

</div>

it would honestly seem custom incremental strategies are not supported for the BigQuery adapter! You’ll notice that in Snowflake, for example, they use an [adapter method](https://github.com/dbt-labs/dbt-snowflake/blob/7e1c1c70c95b87796083b4caa3077221444432d2/dbt/include/snowflake/macros/materializations/incremental.sql#L121) to get your strategy macro, but in BigQuery they do [no such thing](https://github.com/dbt-labs/dbt-bigquery/blob/6c0afe4cfb69761dada5d16150fe632b8f72bf39/dbt/include/bigquery/macros/materializations/incremental.sql#L74C21-L74C67). [This macro](https://github.com/dbt-labs/dbt-bigquery/blob/6c0afe4cfb69761dada5d16150fe632b8f72bf39/dbt/include/bigquery/macros/materializations/incremental.sql#L1) throws an error unless you supply it with `insert_overwrite` or `merge`. I suggest just creating your own materialization and just copying/using the [current incremental materialization](https://github.com/dbt-labs/dbt-bigquery/blob/6c0afe4cfb69761dada5d16150fe632b8f72bf39/dbt/include/bigquery/macros/materializations/incremental.sql#L63) as a starting point.
