Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ca3dfcb
placeholder outline
sungchun12 Dec 19, 2022
9bb5245
add version blocks
sungchun12 Dec 19, 2022
99673b8
add to sidebar
sungchun12 Dec 19, 2022
4dc1c09
remove version blocks
sungchun12 Dec 19, 2022
1dea692
add 2 sections
sungchun12 Dec 19, 2022
ddeae87
postgres section example
sungchun12 Dec 19, 2022
8b5f874
add more docs
sungchun12 Dec 19, 2022
8788c7c
correct DDL
sungchun12 Dec 19, 2022
56004bd
correct config name
sungchun12 Dec 19, 2022
6fc8c70
fix data type
sungchun12 Dec 19, 2022
6e93abe
add redshift docs
dave-connors-3 Dec 21, 2022
769053e
Update constraints docs for Snowflake
b-per Dec 21, 2022
08daa11
Merge branch 'dbt-constraints-docs' of github.com:dbt-labs/docs.getdb…
b-per Dec 21, 2022
bff560e
Merge branch 'current' of https://github.com/dbt-labs/docs.getdbt.com…
sungchun12 Jan 3, 2023
bcdc1fa
add model config links
sungchun12 Jan 3, 2023
2d04d37
update warehouse to spark
sungchun12 Jan 3, 2023
63475b8
update not null syntax
sungchun12 Jan 3, 2023
2b0fc9e
add more config examples
sungchun12 Jan 4, 2023
c33f705
fix ordering
sungchun12 Jan 4, 2023
dc6634f
update docs based on new parsing
sungchun12 Jan 9, 2023
e295c43
add a note
sungchun12 Jan 17, 2023
181a07d
add example error messages
sungchun12 Feb 3, 2023
82a4752
Update config name on Redshift
b-per Feb 3, 2023
1df2052
Update description for Spark
b-per Feb 3, 2023
f97d987
add explainers
sungchun12 Feb 16, 2023
92eb51c
add check
sungchun12 Feb 16, 2023
b0243ff
remove fluff
sungchun12 Feb 16, 2023
f98639a
Merge branch 'current' into dbt-constraints-docs
sungchun12 Feb 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add redshift docs
  • Loading branch information
dave-connors-3 committed Dec 21, 2022
commit 6e93abee95eaa55493942efc729d7dbd9ade27f5
79 changes: 77 additions & 2 deletions website/docs/reference/resource-configs/constraints_enabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can manage data type constraints on your models using the `constraints_enabl

## Configuring Constraints

You can configure `constraints_enabled` in `dbt_project.yml` to apply constraints to many resources at once—all models in your project, a package, or a subfolder—and you can also configure grants one-by-one for specific resources, in yaml config: blocks or right within their .sql files. You'll receive dynamic error messages if you do not configure constraints based on the criteria below.
You can configure `constraints_enabled` in `dbt_project.yml` to apply constraints to many resources at once—all models in your project, a package, or a subfolder—and you can also configure grants one-by-one for specific resources, in yaml config: blocks or right within their `.sql` files. You'll receive dynamic error messages if you do not configure constraints based on the criteria below.

Constraints must be defined in a `yml` schema configuration file like `schema.yml`.

Expand Down Expand Up @@ -119,7 +119,82 @@ models:

<div warehouse="Redshift">

* No special requirements at this time.
Redshift currently only enforces `not null` constraints; all other constraints are metadata only. Additionally, Redshift does not allow column checks at the time of table creation. See more in the Redshift documentation [here](https://docs.aws.amazon.com/redshift/latest/dg/t_Defining_constraints.html).

<File name='models/constraints_example.sql'>

```sql
{{
config(
materialized = "table"
)
}}

select
1 as id,
'blue' as color,
cast('2019-01-01' as date) as date_day
```

</File>

<File name='models/schema.yml'>

```yml
models:
- name: constraints_example
docs:
node_color: black
config:
constraints_enabled: true
columns:
- name: id
data_type: integer
description: hello
constraints: ['not null','primary key']
check: (id > 0)
tests:
- unique
- name: color
data_type: varchar
- name: date_day
data_type: date
```

</File>

Expected DDL to enforce constraints:
<File name='target/run/.../constraints_example.sql'>

```sql

create table
"database_name"."schema_name"."my_model__dbt_tmp"

(
id integer not null,
color varchar,
date_day date,
primary key(id)
)



;
insert into "database_name"."schema_name"."my_model__dbt_tmp"
(

select
1 as id,
'blue' as color,
cast('2019-01-01' as date) as date_day
)
;

```

</File>


</div>

Expand Down