-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-1913] Snapshot target_schema & target_database used from dbt_project.yml #6745
Comments
Thank you for reaching out about this @minhajpasha ! p.s. I added some I was able to reproduce what you described, and I agree this is a bug. It might be related to #4000 WorkaroundRemoving your But if you want to keep that file (for its column descriptions, etc), then you can use the following workaround. Remove each version: 2
snapshots:
- name: customers
columns:
- name: customer_id
description: 'customer unique id' And add your specific
How to reproduceHere's the simplified setup that I used to reproduce the error using dbt-snowflake:
snapshots:
+target_schema: dbeatty_snapshot_dataset
{% snapshot customers %}
{{
config(
enabled=true,
unique_key='id',
strategy='check',
check_cols='all',
)
}}
select 0 as id
{% endsnapshot %} This will not work as intended (since it won't use configured the snapshot version: 2
snapshots:
- name: customers
# Adding a config section here will break the snapshot `target_schema`!
config:
enabled: true Run itRun it and observe the (unintended!) schema it uses for snapshots: dbt snapshot --select customers But removing the version: 2
snapshots:
- name: customers Run it againRun it again and observe the intended schema it uses for snapshots: dbt snapshot --select customers |
@dbeatty10 - I hope everything is going well for you. Thanks for providing the workaround. Will try and update you |
This bug also applies when defining a "meta" property in the snapshot yml (so not just config). |
@honeyp0t -- thanks for explaining that this extends beyond |
I've been pulling my hair over an issue with setting the snapshot database as well. Is this related? dbt_project.yml
snapshot_name.sql (with simply hard coded database)
My dbt snapshot runs would ignore these settings and use the database from profiles.yml, just like the schema issue noted above. dbt_project.yml
This works. snapshot_name.sql
This also works. I upgraded from v1.0 to v1.3 and I believe it happened between these versions. |
@dbeatty10 Thanks for the great reproduction case above! One thing I noticed is that the dbt-core/core/dbt/parser/snapshots.py Lines 38 to 40 in 4c63b63
That logic all happens correctly, but then we call So, the idea here is: We need to make sure that, for snapshots, |
We also just hit this bug as we're adding |
Per #7946: This is apparently a regression from v1.2 → v1.3. At this point, we'd be most likely to fix for the next minor version, and (if the fix is precise enough) backport for inclusion in the previous version's next patch |
Is this a new bug in dbt-core?
Current Behavior
Profiles.yml
snapshot config in dbt_project.yml
schema.yml to add the descriptions to snapshots tables
snapshot folder structure:
When we add the schema.yml file under snapshots/primary/snapshots_models and run the below command
dbt snapshot --select customers
then the model is getting created under holding dataset(profile.yml) instead of snapshot_dataset(dbt_project.yml)Expected Behavior
The snapshots should be created in the dataset defined in dbt_project.yml file. For now have removed the schema.yml file so that it can create the model's under dataset provided in dbt_project.yml file. This is stopping to add the descriptions to table columns
Steps To Reproduce
details provide in descriptions
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
bigquery
Additional Context
No response
The text was updated successfully, but these errors were encountered: