Creating a custom 'check' strategy

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.

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:

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, 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!

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

  {%- 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.