From c81c5e9d617e9e94cf0180ded48331fdfbd4e84d Mon Sep 17 00:00:00 2001
From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com>
Date: Fri, 20 Dec 2024 22:21:18 +0000
Subject: [PATCH] add missing snapshot yaml examples (#6674)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Some of the resources listed under the general config pages don't have
the updated 1.9+ YAML configs listed or mentioned.
This PR updates the snapshot tabs to show the YAML configuration for the
resources missing it.
Resolves #6382
---
🚀 Deployment available! Here are the direct links to the updated files:
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/alias
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/contract
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/database
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/enabled
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/group
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/persist_docs
-
https://docs-getdbt-com-git-add-snapshot-yaml-dbt-labs.vercel.app/reference/resource-configs/schema
---------
Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com>
---
.../docs/reference/resource-configs/alias.md | 9 +++--
.../reference/resource-configs/contract.md | 2 --
.../reference/resource-configs/database.md | 17 +++++++++-
.../reference/resource-configs/enabled.md | 22 +++++++++++--
.../docs/reference/resource-configs/group.md | 15 +++++++++
.../resource-configs/persist_docs.md | 17 ++++++++++
.../docs/reference/resource-configs/schema.md | 33 ++++++++++++++++---
7 files changed, 100 insertions(+), 15 deletions(-)
diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md
index 9b367f7b48a..16a8a392e06 100644
--- a/website/docs/reference/resource-configs/alias.md
+++ b/website/docs/reference/resource-configs/alias.md
@@ -101,7 +101,7 @@ seeds:
-Configure a snapshots's alias in your `dbt_project.yml` file or config block.
+Configure a snapshots's alias in your `dbt_project.yml` file, `snapshots/snapshot_name.yml` file, or config block.
The following examples demonstrate how to `alias` a snapshot named `your_snapshot` to `the_best_snapshot`.
@@ -117,18 +117,17 @@ snapshots:
```
-In the `snapshots/properties.yml` file:
+In the `snapshots/snapshot_name.yml` file:
-
+
```yml
version: 2
snapshots:
- - name: your_snapshot
+ - name: your_snapshot_name
config:
alias: the_best_snapshot
-```
In `snapshots/your_snapshot.sql` file:
diff --git a/website/docs/reference/resource-configs/contract.md b/website/docs/reference/resource-configs/contract.md
index 18266ec672f..bd1fceb4e9b 100644
--- a/website/docs/reference/resource-configs/contract.md
+++ b/website/docs/reference/resource-configs/contract.md
@@ -6,8 +6,6 @@ default_value: {enforced: false}
id: "contract"
---
-Supported in dbt v1.5 and higher.
-
When the `contract` configuration is enforced, dbt will ensure that your model's returned dataset exactly matches the attributes you have defined in yaml:
- `name` and `data_type` for every column
- Additional [`constraints`](/reference/resource-properties/constraints), as supported for this materialization and data platform
diff --git a/website/docs/reference/resource-configs/database.md b/website/docs/reference/resource-configs/database.md
index 6c57e7e2c69..16742b3f597 100644
--- a/website/docs/reference/resource-configs/database.md
+++ b/website/docs/reference/resource-configs/database.md
@@ -22,6 +22,7 @@ models:
```
+
This would result in the generated relation being located in the `reporting` database, so the full relation name would be `reporting.finance.sales_metrics` instead of the default target database.
@@ -55,7 +56,7 @@ Available for dbt Cloud release tracks or dbt Core v1.9+. Select v1.9 or newer f
-Specify a custom database for a snapshot in your `dbt_project.yml` or config file.
+Specify a custom database for a snapshot in your `dbt_project.yml`, snapshot.yml file, or config file.
For example, if you have a snapshot that you want to load into a database other than the target database, you can configure it like this:
@@ -69,6 +70,20 @@ snapshots:
```
+Or in a `snapshot_name.yml` file:
+
+
+
+```yaml
+version: 2
+
+snapshots:
+ - name: snapshot_name
+ [config](/reference/resource-properties/config):
+ database: snapshots
+```
+
+
This results in the generated relation being located in the `snapshots` database so the full relation name would be `snapshots.finance.your_snapshot` instead of the default target database.
diff --git a/website/docs/reference/resource-configs/enabled.md b/website/docs/reference/resource-configs/enabled.md
index b74d7250907..faee6654b22 100644
--- a/website/docs/reference/resource-configs/enabled.md
+++ b/website/docs/reference/resource-configs/enabled.md
@@ -78,9 +78,28 @@ snapshots:
+
+
+
+
+```yaml
+version: 2
+
+snapshots:
+ - name: snapshot_name
+ [config](/reference/resource-properties/config):
+ enabled: true | false
+```
+
+
+
+
+
```sql
+# Configuring in a SQL file is a legacy method and not recommended. Use the YAML file instead.
+
{% snapshot [snapshot_name](snapshot_name) %}
{{ config(
@@ -90,11 +109,10 @@ snapshots:
select ...
{% endsnapshot %}
-
```
-
+
diff --git a/website/docs/reference/resource-configs/group.md b/website/docs/reference/resource-configs/group.md
index cd0ad2683f5..5ea701b3b63 100644
--- a/website/docs/reference/resource-configs/group.md
+++ b/website/docs/reference/resource-configs/group.md
@@ -96,6 +96,21 @@ snapshots:
+
+
+
+```yaml
+version: 2
+
+snapshots:
+ - name: snapshot_name
+ [config](/reference/resource-properties/config):
+ group: GROUP_NAME
+```
+
+
+
+
```sql
diff --git a/website/docs/reference/resource-configs/persist_docs.md b/website/docs/reference/resource-configs/persist_docs.md
index d4a90027771..68a23274b4b 100644
--- a/website/docs/reference/resource-configs/persist_docs.md
+++ b/website/docs/reference/resource-configs/persist_docs.md
@@ -84,6 +84,23 @@ snapshots:
+
+
+
+```yaml
+version: 2
+
+snapshots:
+ - name: snapshot_name
+ [config](/reference/resource-properties/config):
+ persist_docs:
+ relation: true
+ columns: true
+```
+
+
+
+
```sql
diff --git a/website/docs/reference/resource-configs/schema.md b/website/docs/reference/resource-configs/schema.md
index 6f56215de61..1b5a2d83c45 100644
--- a/website/docs/reference/resource-configs/schema.md
+++ b/website/docs/reference/resource-configs/schema.md
@@ -22,13 +22,14 @@ models:
```
+
This would result in the generated relations for these models being located in the `marketing` schema, so the full relation names would be `analytics.target_schema_marketing.model_name`. This is because the schema of the relation is `{{ target.schema }}_{{ schema }}`. The [definition](#definition) section explains this in more detail.
-Configure a custom schema in your `dbt_project.yml` file.
+Configure a [custom schema](/docs/build/custom-schemas#understanding-custom-schemas) in your `dbt_project.yml` file.
For example, if you have a seed that should be placed in a separate schema called `mappings`, you can configure it like this:
@@ -50,16 +51,18 @@ This would result in the generated relation being located in the `mappings` sche
-Available in dbt Core v1.9+. Select v1.9 or newer from the version dropdown to view the configs. Try it now in the [dbt Cloud "Latest" release track](/docs/dbt-versions/cloud-release-tracks).
+Available in dbt Core v1.9 and higher. Select v1.9 or newer from the version dropdown to view the configs. Try it now in the [dbt Cloud "Latest" release track](/docs/dbt-versions/cloud-release-tracks).
-Specify a custom schema for a snapshot in your `dbt_project.yml` or config file.
+Specify a [custom schema](/docs/build/custom-schemas#understanding-custom-schemas) for a snapshot in your `dbt_project.yml` or YAML file.
For example, if you have a snapshot that you want to load into a schema other than the target schema, you can configure it like this:
+In a `dbt_project.yml` file:
+
```yml
@@ -70,6 +73,21 @@ snapshots:
```
+In a `snapshots/snapshot_name.yml` file:
+
+
+
+```yaml
+version: 2
+
+snapshots:
+ - name: snapshot_name
+ [config](/reference/resource-properties/config):
+ schema: snapshots
+```
+
+
+
This results in the generated relation being located in the `snapshots` schema so the full relation name would be `analytics.snapshots.your_snapshot` instead of the default target schema.
@@ -78,20 +96,25 @@ This results in the generated relation being located in the `snapshots` schema s
+Specify a [custom schema](/docs/build/custom-schemas#understanding-custom-schemas) for a [saved query](/docs/build/saved-queries#parameters) in your `dbt_project.yml` or YAML file.
+
```yml
saved-queries:
+schema: metrics
```
+
+This would result in the saved query being stored in the `metrics` schema.
+
+
-Customize the schema for storing test results in your `dbt_project.yml` file.
+Customize a [custom schema](/docs/build/custom-schemas#understanding-custom-schemas) for storing test results in your `dbt_project.yml` file.
For example, to save test results in a specific schema, you can configure it like this:
-
```yml