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

Update constraints.md #3736

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Changes from all commits
Commits
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
57 changes: 56 additions & 1 deletion website/docs/reference/resource-properties/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,62 @@ models:

</File>

Expected DDL to enforce constraints:
### Column-level constraint on nested column:
matthewshaver marked this conversation as resolved.
Show resolved Hide resolved

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

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

select
'string' as a,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if this example were more "real world" but this gets the point across.

struct(
1 as id,
'name' as name,
struct(2 as id, struct('test' as again, '2' as even_more) as another) as double_nested
) as b
```

</File>

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

```yml
version: 2

models:
- name: nested_column_constraints_example
config:
contract:
enforced: true
columns:
- name: a
data_type: string
- name: b.id
data_type: integer
constraints:
- type: not_null
- name: b.name
description: test description
data_type: string
- name: b.double_nested.id
data_type: integer
- name: b.double_nested.another.again
data_type: string
- name: b.double_nested.another.even_more
data_type: integer
constraints:
- type: not_null
```

</File>

### Expected DDL to enforce constraints:
runleonarun marked this conversation as resolved.
Show resolved Hide resolved

<File name='target/run/.../constraints_example.sql'>

```sql
Expand Down
Loading