Skip to content

Commit

Permalink
Remove old workarounds (#6133)
Browse files Browse the repository at this point in the history
## What are you changing in this pull request and why?

Remove target_schema workarounds since they no longer apply with v1.9+
native support for environment-aware snapshots.

## Checklist
- [x] I have reviewed the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [x] The topic I'm writing about is for specific dbt version(s) and I
have versioned it according to the [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and/or [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content)
guidelines.
- [x] Needs PM review
  • Loading branch information
nghi-ly authored Sep 25, 2024
1 parent b1468b4 commit 423e48f
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions website/docs/reference/resource-configs/target_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ description: "Target_schema - Read this in-depth guide to learn about configurat
datatype: string
---

:::note
:::info

For [versionless](/docs/dbt-versions/core-upgrade/upgrading-to-v1.8#versionless) dbt Cloud accounts and dbt Core v1.9+, this functionality is no longer required. Use the [schema](/reference/resource-configs/schema) config as an alternative to define a custom schema while still respecting the `generate_schema_name` macro.
For [versionless](/docs/dbt-versions/core-upgrade/upgrading-to-v1.8#versionless) dbt Cloud accounts and dbt Core v1.9+, this configuration is no longer required. Use the [schema](/reference/resource-configs/schema) config as an alternative to define a custom schema while still respecting the `generate_schema_name` macro.

:::

Expand All @@ -33,12 +33,14 @@ snapshots:
</File>

## Description
The schema that dbt should build a [snapshot](/docs/build/snapshots) <Term id="table" /> into. Snapshots build into the same `target_schema`, no matter who is running them.
The schema that dbt should build a [snapshot](/docs/build/snapshots) <Term id="table" /> into. When `target_schema` is provided, snapshots build into the same `target_schema`, no matter who is running them.

On **BigQuery**, this is analogous to a `dataset`.

## Default
This is a **required** parameter, no default is provided.

<VersionBlock lastVersion="1.8" >This is a required parameter, no default is provided. </VersionBlock>
<VersionBlock firstVersion="1.9.1">For versionless dbt Cloud accounts and dbt Core v1.9+, this is not a required parameter. </VersionBlock>

## Examples
### Build all snapshots in a schema named `snapshots`
Expand All @@ -53,38 +55,10 @@ snapshots:

</File>

### Use a target-aware schema
Use the [`{{ target }}` variable](/reference/dbt-jinja-functions/target) to change which schema a snapshot <Term id="table" /> is built in.

Note: consider whether this use-case is right for you, as downstream `refs` will select from the `dev` version of a snapshot, which can make it hard to validate models that depend on snapshots (see above [FAQ](#faqs))

<File name='dbt_project.yml'>

```yml
snapshots:
+target_schema: "{% if target.name == 'prod' %}snapshots{% else %}{{ target.schema }}{% endif %}"

```

</File>
<VersionBlock lastVersion="1.8" >

### Use the same schema-naming behavior as models

Leverage the [`generate_schema_name` macro](/docs/build/custom-schemas) to build snapshots in schemas that follow the same naming behavior as your models.

Notes:
* This macro is not available when configuring from the `dbt_project.yml` file, so must be configured in a snapshot config block.
* Consider whether this use-case is right for you, as downstream `refs` will select from the `dev` version of a snapshot, which can make it hard to validate models that depend on snapshots (see above [FAQ](#faqs))

For native support of environment-aware snapshots, upgrade to dbt Core version 1.9+ and remove any existing `target_schema` configuration.

<File name='snapshots/orders_snapshot.sql'>

```sql
{{
config(
target_schema=generate_schema_name('snapshots')
)
}}
```

</File>
</VersionBlock>

0 comments on commit 423e48f

Please sign in to comment.