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

[dbt-core issue #10301] snapshots now can optionally respect generate schema/database/alias macros #5805

Closed
1 task done
graciegoheen opened this issue Jul 18, 2024 · 0 comments · Fixed by #5817
Closed
1 task done
Assignees
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@graciegoheen
Copy link
Collaborator

graciegoheen commented Jul 18, 2024

Contributions

  • I have read the contribution docs, and understand what's expected of me.

Link to the page on docs.getdbt.com requiring updates

We need to update our snapshot documentation. Here's some initial pages I've identified as needing updates:

I think we likely want to remove target_schema and target_database configs from all of our snapshot examples - perhaps replace those with schema and database.

I think our best practice is still building your snapshots in a separate schema to avoid accidentally dropping them. They are not like models where if you drop them you can just rebuild them; dropping snapshots leads to losing all of your historical data.

What part(s) of the page would you like to see updated?

Historically, snapshots require you set set an explicit target_schema (you can also set an explicit target_database) - meaning by default, regardless of what environment you're in (dev, ci, prod, etc.), when you run dbt snapshot it will build to the same table.

This can be problematic when trying to test out changes to existing snapshot or develop a new snapshot. Now that we have deferral and dbt clone, it no longer makes sense that snapshots wouldn't respect generate_schema_name / generate_database_name/ generate_alias_name like other resources (models, seeds, etc.).

Changes:

  • target_schema is now optional for snapshots
  • if you do not set target_schema, your snapshot will respect generate_schema_name macro
  • if you do not set target_database, your snapshot will respect generate_schema_name macro
  • old behavior continues to work for backwards compatibility: so you can still set target_schema and/or target_database and that will be where your snapshot is built, but these are "old" configs
  • new configs for snapshots: you can now set database, schema, alias for your snapshots to be used by the generate_x_name macros

Additional information

From dbt-core issue dbt-labs/dbt-core#10301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants