Skip to content

Commit

Permalink
Merge branch 'current' into dbt-copilot-note
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Dec 13, 2024
2 parents 64beaf0 + 4705cdd commit f0aa638
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion website/docs/reference/dbt-jinja-functions/env_var.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $ DBT_ENV_CUSTOM_ENV_MY_FAVORITE_COLOR=indigo DBT_ENV_CUSTOM_ENV_MY_FAVORITE_NUM
```
Compiles to:
```sql
-- {'MY_FAVORITE_COLOR': 'indigo', 'DBT_ENV_CUSTOM_ENV_MY_FAVORITE_NUMBER': '6'}
-- {'MY_FAVORITE_COLOR': 'indigo', 'MY_FAVORITE_NUMBER': '6'}
select 1 as id
```
Expand Down
11 changes: 6 additions & 5 deletions website/docs/reference/node-selection/defer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ dbt test --models [...] --defer --state path/to/artifacts

</VersionBlock>

When the `--defer` flag is provided, dbt will resolve `ref` calls differently depending on two criteria:
1. Is the referenced node included in the model selection criteria of the current run?
2. Does the referenced node exist as a database object in the current environment?
By default, dbt uses the [`target`](/reference/dbt-jinja-functions/target) namespace to resolve `ref` calls.

If the answer to both is **no**—a node is not included _and_ it does not exist as a database object in the current environment—references to it will use the other namespace instead, provided by the state manifest.
When `--defer` is enabled, dbt resolves ref calls using the state manifest instead, but only if:

1. The node isn’t among the selected nodes, _and_
2. It doesn’t exist in the database (or `--favor-state` is used).

Ephemeral models are never deferred, since they serve as "passthroughs" for other `ref` calls.

Expand All @@ -46,7 +47,7 @@ Deferral requires both `--defer` and `--state` to be set, either by passing flag

#### Favor state

You can optionally skip the second criterion by passing the `--favor-state` flag. If passed, dbt will favor using the node defined in your `--state` namespace, even if the node exists in the current target.
When `--favor-state` is passed, dbt prioritizes node definitions from the `--state directory`. However, this doesn’t apply if the node is also part of the selected nodes.

### Example

Expand Down
13 changes: 7 additions & 6 deletions website/docs/reference/resource-configs/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ When the `contract` configuration is enforced, dbt will ensure that your model's

This is to ensure that the people querying your model downstream—both inside and outside dbt—have a predictable and consistent set of columns to use in their analyses. Even a subtle change in data type, such as from `boolean` (`true`/`false`) to `integer` (`0`/`1`), could cause queries to fail in surprising ways.

## Support

At present, model contracts are supported for:
- SQL models (not yet Python)
- Models materialized as `table`, `view`, and `incremental` (with `on_schema_change: append_new_columns` or `on_schema_change: fail`)
- The most popular data platforms — though support and enforcement of different [constraint types](/reference/resource-properties/constraints) vary by platform

## Data type aliasing

dbt uses built-in type aliasing for the `data_type` defined in your YAML. For example, you can specify `string` in your contract, and on Postgres/Redshift, dbt will convert it to `text`. If dbt doesn't recognize the `data_type` name among its known aliases, it will pass it through as-is. This is enabled by default, but you can opt-out by setting `alias_types` to `false`.
Expand Down Expand Up @@ -91,12 +98,6 @@ When you `dbt run` your model, _before_ dbt has materialized it as a table in th
20:53:45 > in macro assert_columns_equivalent (macros/materializations/models/table/columns_spec_ddl.sql)
```

## Support

At present, model contracts are supported for:
- SQL models (not yet Python)
- Models materialized as `table`, `view`, and `incremental` (with `on_schema_change: append_new_columns`)
- The most popular data platforms — though support and enforcement of different [constraint types](/reference/resource-properties/constraints) vary by platform

### Incremental models and `on_schema_change`

Expand Down

0 comments on commit f0aa638

Please sign in to comment.