# Creating a custom 'check' strategy

**URL:** <https://discourse.getdbt.com/t/creating-a-custom-check-strategy/5996>\
**Category:** Help\
**Tags:** snapshots\
**Created:** [January 11, 2023, 12:35pm UTC](https://discourse.getdbt.com/t/creating-a-custom-check-strategy/5996 "2023-01-11T12:35:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhan\_c](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dhan\_c](https://discourse.getdbt.com/u/dhan_c)\
**Post date:** [January 11, 2023, 12:35pm UTC](https://discourse.getdbt.com/t/creating-a-custom-check-strategy/5996/1 "2023-01-11T12:35:06Z")

</div>

Hi all,

I’m trying to create a custom snapshot strategy which changes the way in which hard deletes are invalidated.

I have created a custom `check` strategy by creating a new macro based off the original found [here](https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql#L131).

However when I reference my new check strategy in the snapshot config block, I’m receiving an error which relates to another macro (a macro that I have not changed): `snapshot_check_all_get_existing_columns`

The following error is received:

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

I have tried to troubleshoot by using the default `check` strategy definition/logic but I still receive the same error message.

The macro causing the error definitely takes in 3 args as shown [here](https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql#L93), so really not sure why the error message received states differently.

Any help in understanding the cause of this issue would be much appreciated.

Thanks all!

---

<div class="post-metadata">

**Author:** ![nitami](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nitami](https://discourse.getdbt.com/u/nitami)\
**Post date:** [October 2, 2024, 11:36am UTC](https://discourse.getdbt.com/t/creating-a-custom-check-strategy/5996/2 "2024-10-02T11:36:05Z")

</div>

I know this question is posted a long time ago and you’ve probably found the solution already. Just in case anybody stumbles upon this, like I just did today, the issue is related to your macro name. In the source code that is linked in the documentation, [`macros/materializations/snapshots/strategies.sql`](https://github.com/dbt-labs/dbt-adapters/blob/10e6d59e1cb6cc53c4e92ab37dac817641f66f2f/dbt/include/global_project/macros/materializations/snapshots/strategies.sql#L23)

```auto
  {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}

  {% if search_name not in package_context %}
    {% set error_msg %}
        The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'
    {% endset %}
    {{ exceptions.raise_compiler_error(error_msg | trim) }}
  {% endif %}
  {{ return(package_context[search_name]) }}
{%- endmacro %}

```

the dispatched macro dbt is looking for is `snapshot_{name}_strategy`, with `name` being the strategy value you define in your snapshot config.

This is also applies when we use the built in strategy, for example, `"timestamp"` strategy, the associated macro that is called is `"snapshot_timestamp_strategy"` that’s defined in dbt source code.

So in your case, you must rename your macro name accordingly.

**Edit:** I just realized the documentation is already clear enough about this naming rule.
