Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-3359] [Bug] A snapshot block with no name fails without providing the offending file path #9033

Closed
2 tasks done
joellabes opened this issue Nov 8, 2023 · 1 comment
Closed
2 tasks done
Labels
bug Something isn't working snapshots Issues related to dbt's snapshot functionality

Comments

@joellabes
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I was testing some snapshot behaviour and freewheeled the first bit:

{% snapshot %}

{% endsnapshot %}

before remembering that there was a chunk of config I needed to copy-paste, so I went and grabbed that from the docs and wound up with:

{% snapshot %}
{{
    config(
      target_database='analytics',
      target_schema='snapshots',
      unique_key='id',

      strategy='check',
      check_cols='all'
    )
}}
select 1 as id
{% endsnapshot %}

I added some other sql model and yaml files, and then tried to do a dbt run, where I got this error:

01:40:21  Encountered an error:
Parsing Error
  at path ['name']: None is not of type 'string'

I couldn't work out what was missing, and spent 10mins doing a global search for name and deleting files to try and track down the issue.

It turns out that I didn't provide a name for the snapshot.

{% snapshot like_this %}

{% endsnapshot %]

Expected Behavior

The error message to indicate where the snapshot was missing.

Minimum:

              ↓     this bit is new!        ↓
Parsing Error in snapshots/first_snapshot.sql
  at path ['name']: None is not of type 'string'

Ideally:

Parsing Error in snapshots/first_snapshot.sql
  A snapshot block does not include a name. See https://docs.getdbt.com/docs/build/snapshots

Better still:
In dbt v2, let's make snapshots behave like every other node type, with only one per file and no opening/closing snapshot blocks.

Steps To Reproduce

--snapshots/my_snapshot.sql
{% snapshot %}

select 1 as id

{% endsnapshot %}

Relevant log output

No response

Environment

- OS:
- Python:
- dbt: 1.7.0

Which database adapter are you using with dbt?

No response

Additional Context

No response

@joellabes joellabes added bug Something isn't working triage labels Nov 8, 2023
@github-actions github-actions bot changed the title [Bug] A snapshot block with no name fails without providing the offending file path [CT-3359] [Bug] A snapshot block with no name fails without providing the offending file path Nov 8, 2023
@dbeatty10 dbeatty10 added the snapshots Issues related to dbt's snapshot functionality label Nov 8, 2023
@dbeatty10
Copy link
Contributor

Yeah!

In an ideal world, you could freewheel and the dbt error messages would give the same experience as bumper bowling and help you knock down the pins build your snapshot. 🎳

I've added your suggested syntax to the acceptance criteria for this preexisting issue:

Also added your particular situation to something to consider when creating the functional tests.

I'm going to close this as a duplicate of #8276. Feel free to add any relevant commentary that I missed into that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snapshots Issues related to dbt's snapshot functionality
Projects
None yet
Development

No branches or pull requests

2 participants