Skip to content

Commit

Permalink
Adapter constraint support tables
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshaver committed Aug 17, 2023
1 parent d2d3a81 commit e0c9f07
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions website/docs/docs/collaborate/govern/model-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,85 @@ When building a model with a defined contract, dbt will do two things differentl
1. dbt will run a "preflight" check to ensure that the model's query will return a set of columns with names and data types matching the ones you have defined. This check is agnostic to the order of columns specified in your model (SQL) or YAML spec.
2. dbt will include the column names, data types, and constraints in the DDL statements it submits to the data platform, which will be enforced while building or updating the model's table.

## Platform constraint support

Adapter-specific constraint support across platforms.

<Tabs>

<TabItem value="Redshift" label="Redshift">

| constraint type | support |
|:----------------|:-------------|
| not_null | πŸŒ• supported & enforced |
| primary_key | πŸŒ— supported; not enforced |
| foreign_key | πŸŒ— supported; not enforced |
| unique | πŸŒ— supported; not enforced |
| check | πŸŒ‘ not supported |

</TabItem>
<TabItem value="Snowflake" label="Snowflake">

| constraint type | support |
|:----------------|:-------------|
| not_null | πŸŒ• supported & enforced |
| primary_key | πŸŒ— supported; not enforced |
| foreign_key | πŸŒ— supported; not enforced |
| unique | πŸŒ— supported; not enforced |
| check | πŸŒ‘ not supported |

</TabItem>
<TabItem value="BigQuery" label="BigQuery">

| constraint type | support |
|:-----------------|:-------------|
| not_null | πŸŒ• supported & enforced |
| primary_key | πŸŒ• supported & enforced |
| foreign_key | πŸŒ• supported & enforced |
| unique | πŸŒ‘ not supported |
| check | πŸŒ‘ not supported |

</TabItem>
<TabItem value="Postgres" label="Postgres">

| constraint type | support |
|:----------------|:-------------|
| not_null | πŸŒ• supported & enforced |
| primary_key | πŸŒ• supported & enforced |
| foreign_key | πŸŒ• supported & enforced |
| unique | πŸŒ• supported & enforced |
| check | πŸŒ• supported & enforced |

</TabItem>
<TabItem value="Spark" label="Spark">

`not_null` and `check` constraints are supported and enforced. In the current implementation, however, these constraints are only enforced after a model builds. Due to this platform limitation, these are considered `supported` but `not enforced` and are not a part of the "model contract" since they can't be enforced at build time. This table will be updated as the features evolve.

| constraint type | support |
|:----------------|:------------|
| not_null | πŸŒ— supported; not enforced |
| primary_key | πŸŒ— supported; not enforced |
| foreign_key | πŸŒ— supported; not enforced |
| unique | πŸŒ— supported; not enforced |
| check | πŸŒ— supported; not enforced |

</TabItem>
<TabItem value="Databricks" label="Databricks">

`not_null` and `check` constraints are supported and enforced. In the current implementation, however, these constraints are only enforced after a model builds. Due to this platform limitation, these are considered `supported` but `not enforced` and are not a part of the "model contract" since they can't be enforced at build time. This table will be updated as the features evolve.

| constraint type | support |
|:----------------|:------------|
| not_null | πŸŒ— supported; not enforced |
| primary_key | πŸŒ— supported; not enforced |
| foreign_key | πŸŒ— supported; not enforced |
| unique | πŸŒ— supported; not enforced |
| check | πŸŒ— supported; not enforced |

</TabItem>
</Tabs>


## FAQs

### Which models should have contracts?
Expand Down

0 comments on commit e0c9f07

Please sign in to comment.