Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated constraints doc following slack #5995

Merged
merged 80 commits into from
Oct 4, 2024
Merged
Changes from 8 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
50998fe
Updated constraints doc following slack
nataliefiann Aug 30, 2024
d738c03
Merge branch 'current' into nfiann-snowflake-constraints
nataliefiann Aug 30, 2024
dc70f56
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
1732a00
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
9368790
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
3ac1d4d
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
70460bb
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
3ea40bd
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
fa43fff
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
4a17642
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
0d834a7
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
a8e26c4
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
e6fe96b
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
cdf0ade
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
9da9e5d
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
85abbd2
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
03fc2a2
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Aug 30, 2024
8851b14
Updated doc, moved section to new location
nataliefiann Sep 2, 2024
6141055
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Sep 2, 2024
7fc710a
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 2, 2024
8f7cd16
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 2, 2024
43d6cf5
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 2, 2024
8295508
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
f8cce33
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
04bf56d
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
2455fb5
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
70ad260
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
72420bd
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
7d2287d
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
e10b826
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
244e2f4
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
8258226
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
2cf8771
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
15f7664
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 3, 2024
05afe4e
updated doc
nataliefiann Sep 4, 2024
eb1b5bf
Merge branch 'current' into nfiann-snowflake-constraints
nataliefiann Sep 4, 2024
d9290f0
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
3fea390
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
278f3d5
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
f3bced0
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
88f16f0
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
bb6c5ea
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
fb6e44d
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
9cfc253
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
1a7b84e
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
84ec68c
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
b4285e7
update yaml
nataliefiann Sep 4, 2024
35cc43e
Merge branch 'nfiann-snowflake-constraints' of https://github.com/dbt…
nataliefiann Sep 4, 2024
2ff1603
Merge branch 'current' into nfiann-snowflake-constraints
nataliefiann Sep 4, 2024
5217d03
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
3885b93
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 4, 2024
8f7afb7
Merge branch 'current' into nfiann-snowflake-constraints
nataliefiann Sep 9, 2024
ecff6de
Updated project splitting section
nataliefiann Sep 10, 2024
55f9a4c
Update website/docs/best-practices/how-we-structure/5-the-rest-of-the…
nataliefiann Sep 10, 2024
b5d2a45
Update website/docs/best-practices/how-we-structure/5-the-rest-of-the…
nataliefiann Sep 10, 2024
f40d5b3
Changed order of paragraph around
nataliefiann Sep 10, 2024
b31bf86
Merge branch 'nfiann-project-splitting' of https://github.com/dbt-lab…
nataliefiann Sep 10, 2024
63c9b46
Update website/docs/best-practices/how-we-structure/5-the-rest-of-the…
nataliefiann Sep 10, 2024
0e78924
Updated project splitting section (#6043)
nataliefiann Sep 10, 2024
62870a4
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Sep 11, 2024
1207ce2
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
b7cd506
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
ee54034
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Sep 11, 2024
d7eb830
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
6f7b622
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
b72d530
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
261d61f
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
4274678
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
86038b6
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
a9b4418
Update website/docs/reference/resource-properties/constraints.md
nataliefiann Sep 11, 2024
bb94cfe
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Sep 12, 2024
c9b93bf
Update website/docs/reference/resource-properties/constraints.md
mirnawong1 Sep 12, 2024
fce1c45
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 2, 2024
e9b8223
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 3, 2024
1997af4
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 3, 2024
fa0da23
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 3, 2024
d05793c
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 3, 2024
749dc8a
Merge branch 'current' into nfiann-snowflake-constraints
mirnawong1 Oct 4, 2024
3ae24bd
Update constraints.md
mirnawong1 Oct 4, 2024
06384c6
Update constraints.md
mirnawong1 Oct 4, 2024
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
60 changes: 60 additions & 0 deletions website/docs/reference/resource-properties/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,66 @@ select

</File>

### Custom constraints on models for advanced configuration of tables

In dbt Cloud, you can use custom constraints on models for advanced configuration of tables. For example, custom constraints allow you to set [masking policies](https://docs.snowflake.com/en/user-guide/security-column-intro#what-are-masking-policies) in Snowflake when using a Create Table As Select (CTAS).

Each data warehouse has its own set of parameters that can be set for columns in their CTAS statements. For example [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-ddl-create-table-using.html) and [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#column_name_and_column_schema)".


Contracts and constraints support tag-based masking policies using the following syntax:
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved

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

```yaml

models:
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved

- name: my_model
config:
contract: {enforced: true}
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
materialized: table
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
columns:
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
- name: id
data_type: int
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
constraints:
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved
- type: custom
expression: "tag (my_tag = 'my_value')" # A custom SQL expression used to enforce a specific constraint on a column.
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved

```

</File>

Using this syntax requires configuring all the columns and their types as it’s the only way where to send a create or replace `<cols_info_with_masking> mytable as ...`. It’s not possible to do it with just a partial list of columns. This means making sure the columns and constraints fields are fully defined.

To generate a YAML with all the columns, you could also use `generate_model_yaml` from [dbt-codegen](https://github.com/dbt-labs/dbt-codegen/tree/0.12.1/?tab=readme-ov-file#generate_model_yaml-source).

Alternatively, you can add a masking policy without tags:

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

```shell
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved

models:
- name: my_model
config:
contract: {enforced: true}
materialized: table
columns:
- name: id
data_type: int
constraints:
- type: custom
expression: "masking policy my_policy"

```

</File>



:::
nataliefiann marked this conversation as resolved.
Show resolved Hide resolved

</div>

<div warehouse="BigQuery">
Expand Down
Loading