Encountered unknown tag 'snapshot' in DBT Snapshot
Asked Answered
L

1

6

I want to run a DBT Snapshot and am following a near-identical template to the one outlined in the documentation. However, I get the error when I run dbt snpashot

Compilation Error in model test_snapshot (.../project_folder/snapshots/test_snapshot.sql)    
Encountered unknown tag 'snapshot'.
        line 1
          {% snapshot test_snapshot %}

Below is the code I am attempting to compile.

{% snapshot test_snapshot %}
    {{
        config(
            strategy='check',
            unique_key='id',
            target_schema='snapshots',
            check_cols= 'all'
        )
    }}

select
        *
from {{ ref('modle_in_sample_folder') }}

{% endsnapshot %}

The order of the snapshot folder and ref file is .../project_folder/snapshots/test_snapshot.sql and .../project_folder/intermediate/model_in_sample_folder.sql

Lovelace answered 26/6, 2022 at 2:31 Comment(2)
I'd advise, as the docs say, to select data from source in the snapshot, and transform the data afterwards, rather than relying on a data model: docs.getdbt.com/docs/building-a-dbt-project/…Furore
What version of dbt are you running? The error is because dbt can't parse the {% snapshot test_snapshot %} line which would happen on a very old version of dbt (<0.14), when snapshots were called archivesScharf
L
8

The problem was the location of my Snapshot folder. Once I moved it out of my models project folder, and up to one level in the folder hierarchy, I was able to run it successfully.

Lovelace answered 30/6, 2022 at 14:48 Comment(1)
NOTE: It should be in the snapshots folder that is created when you init the project.Hock

© 2022 - 2024 — McMap. All rights reserved.