Datavault-UK / automate-dv

A free to use dbt package for creating and loading Data Vault 2.0 compliant Data Warehouses (powered by dbt, an open source data engineering tool, registered trademark of dbt Labs)
https://www.automate-dv.com
Apache License 2.0
478 stars 114 forks source link

[BUG] 20:55:57 'is_vault_insert_by_period' is undefined #204

Closed wil-teampeanut closed 12 months ago

wil-teampeanut commented 12 months ago

Describe the bug I am trying to use the is_vault_insert_by_period() macro in the same way I would the DBT is_incremental() macro in a script, but the following error is raised: 20:55:57 'is_vault_insert_by_period' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

Environment

dbt version: 1.5.2 automate_dv version: 0.9.6 Database/Platform: Snowflake

To Reproduce Steps to reproduce the behavior: I have added this code snippet beneath a config file

{{
    config(
        materialized='vault_insert_by_period',
        period = "day",
        timestamp_field = "timestamp_column",
        start_date = "2019-01-01",
        stop_date = "2023-08-01"
    )
}}

{% if is_vault_insert_by_period() %}
    -- this filter will only be applied on an incremental run
    DELETE FROM {{ this }} WHERE timestamp_column = '2023-7-1'

    {% endif %}

Expected behavior I would expect the delete statement to be called if the table already existed.

DVAlexHiggs commented 12 months ago

As it is a macro provided by AutomateDV, You need to prefix it as follows: automate_dv.is_vault_insert_by_period() please try this and let us know if the issue persists!

wil-teampeanut commented 12 months ago

Yep, sorry, I just recognised what was going on and was about to close the comment. Thanks for getting back to me quickly!