snapshotdbt

DBT Core- Snapshot: Parsing Error at path []: Snapshots must be configured with a ‘strategy’, ‘unique_key’, and ‘target_schema’


In dbt-core, I have created a folder under snapshots called salesforce. All my snapshot sqls are in this folder. Now I have a few common configs that I have added in dbt_project.yml given below:

snapshots:
  salesforce:
    +unique_key: id
    +target_schema: snapshots
    +invalidate_hard_deletes: True

And the remaining configs in my respective sqls in config:

{{
    config(
      strategy='timestamp',
      updated_at='SYSTEM_MODSTAMP',
    )
}}

However, when I run dbt snapshot command with this setup, I get the following error:

Parsing Error at path : Snapshots must be configured with a ‘strategy’, ‘unique_key’, and ‘target_schema’.

When I dont create the salseforce folder under snapshot and add all my sqls directly under snapshot with following configuration it works.

snapshots:
   +unique_key: id
   +target_schema: snapshots
   +invalidate_hard_deletes: True

What am I missing?


Solution

  • You should provide your project name in between:

    snapshots:
      project_name:
        salesforce:
          +unique_key: id
          +target_schema: snapshots
          +invalidate_hard_deletes: True
    

    The project name normally is on the top of your dbt_project.yml.