From e0c9f0785fcf8e33d06e4bf0d87c5ec94d06b458 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Thu, 17 Aug 2023 11:43:42 -0400 Subject: [PATCH 1/7] Adapter constraint support tables --- .../collaborate/govern/model-contracts.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index 339098adbdc..0b3aae97ede 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -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. + + + + + +| constraint type | support | +|:----------------|:-------------| +| not_null | 🌕 supported & enforced | +| primary_key | 🌗 supported; not enforced | +| foreign_key | 🌗 supported; not enforced | +| unique | 🌗 supported; not enforced | +| check | 🌑 not supported | + + + + +| constraint type | support | +|:----------------|:-------------| +| not_null | 🌕 supported & enforced | +| primary_key | 🌗 supported; not enforced | +| foreign_key | 🌗 supported; not enforced | +| unique | 🌗 supported; not enforced | +| check | 🌑 not supported | + + + + +| constraint type | support | +|:-----------------|:-------------| +| not_null | 🌕 supported & enforced | +| primary_key | 🌕 supported & enforced | +| foreign_key | 🌕 supported & enforced | +| unique | 🌑 not supported | +| check | 🌑 not supported | + + + + +| constraint type | support | +|:----------------|:-------------| +| not_null | 🌕 supported & enforced | +| primary_key | 🌕 supported & enforced | +| foreign_key | 🌕 supported & enforced | +| unique | 🌕 supported & enforced | +| check | 🌕 supported & enforced | + + + + +`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 | + + + + +`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 | + + + + + ## FAQs ### Which models should have contracts? From deefb21ed6f63a9035624e4aa88bc85220b6df4e Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:44:58 -0400 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> --- .../collaborate/govern/model-contracts.md | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index 0b3aae97ede..6c6eec678ce 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -88,24 +88,24 @@ When building a model with a defined contract, dbt will do two things differentl ## Platform constraint support -Adapter-specific constraint support across platforms. +Select the adapter-specific tab for more info on adapter-specific constraint support across platforms. -| constraint type | support | +| Constraint type | Support | |:----------------|:-------------| -| not_null | 🌕 supported & enforced | -| primary_key | 🌗 supported; not enforced | -| foreign_key | 🌗 supported; not enforced | +| not_null | 🌕 Supported and enforced | +| primary_key | 🌗 Supported and not enforced | +| foreign_key | 🌗 Supported and not enforced | | unique | 🌗 supported; not enforced | | check | 🌑 not supported | -| constraint type | support | +| Constraint type | Support | |:----------------|:-------------| | not_null | 🌕 supported & enforced | | primary_key | 🌗 supported; not enforced | @@ -116,7 +116,7 @@ Adapter-specific constraint support across platforms. -| constraint type | support | +| Constraint type | Support | |:-----------------|:-------------| | not_null | 🌕 supported & enforced | | primary_key | 🌕 supported & enforced | @@ -127,7 +127,7 @@ Adapter-specific constraint support across platforms. -| constraint type | support | +| Constraint type | Support | |:----------------|:-------------| | not_null | 🌕 supported & enforced | | primary_key | 🌕 supported & enforced | @@ -138,9 +138,9 @@ Adapter-specific constraint support across platforms. -`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. +`not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. -| constraint type | support | +| Constraint type | Support | |:----------------|:------------| | not_null | 🌗 supported; not enforced | | primary_key | 🌗 supported; not enforced | @@ -151,9 +151,10 @@ Adapter-specific constraint support across platforms. -`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. +```suggestion +`not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. -| constraint type | support | +| Constraint type | Support | |:----------------|:------------| | not_null | 🌗 supported; not enforced | | primary_key | 🌗 supported; not enforced | From 517a8fb0ee04895b29286b74c0972519671e416a Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:58:18 -0400 Subject: [PATCH 3/7] Update model-contracts.md --- .../collaborate/govern/model-contracts.md | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index 6c6eec678ce..c69f1ae958c 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -97,43 +97,43 @@ Select the adapter-specific tab for more info on adapter-specific constraint sup | Constraint type | Support | |:----------------|:-------------| | not_null | 🌕 Supported and enforced | -| primary_key | 🌗 Supported and not enforced | +| primary_key | 🌗 Supported and not enforced | | foreign_key | 🌗 Supported and not enforced | -| unique | 🌗 supported; not enforced | -| check | 🌑 not supported | +| unique | 🌗 Supported and not enforced | +| check | 🌑 Not supported | | Constraint type | Support | |:----------------|:-------------| -| not_null | 🌕 supported & enforced | -| primary_key | 🌗 supported; not enforced | -| foreign_key | 🌗 supported; not enforced | -| unique | 🌗 supported; not enforced | -| check | 🌑 not supported | +| not_null | 🌕 Supported and enforced | +| primary_key | 🌗 Supported and not enforced | +| foreign_key | 🌗 Supported and not enforced | +| unique | 🌗 Supported and not enforced | +| check | 🌑 Not supported | | Constraint type | Support | |:-----------------|:-------------| -| not_null | 🌕 supported & enforced | -| primary_key | 🌕 supported & enforced | -| foreign_key | 🌕 supported & enforced | -| unique | 🌑 not supported | -| check | 🌑 not supported | +| not_null | 🌕 Supported and enforced | +| primary_key | 🌕 Supported and enforced | +| foreign_key | 🌕 Supported and enforced | +| unique | 🌑 Not supported | +| check | 🌑 Not supported | | Constraint type | Support | |:----------------|:-------------| -| not_null | 🌕 supported & enforced | -| primary_key | 🌕 supported & enforced | -| foreign_key | 🌕 supported & enforced | -| unique | 🌕 supported & enforced | -| check | 🌕 supported & enforced | +| not_null | 🌕 Supported and enforced | +| primary_key | 🌕 Supported and enforced | +| foreign_key | 🌕 Supported and enforced | +| unique | 🌕 Supported and enforced | +| check | 🌕 Supported and enforced | @@ -142,25 +142,24 @@ Select the adapter-specific tab for more info on adapter-specific constraint sup | 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 | +| not_null | 🌗 Supported and not enforced | +| primary_key | 🌗 Supported and not enforced | +| foreign_key | 🌗 Supported and not enforced | +| unique | 🌗 Supported and not enforced | +| check | 🌗 Supported and not enforced | -```suggestion `not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. -| Constraint type | Support | +| 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 | +| not_null | 🌗 Supported and not enforced | +| primary_key | 🌗 Supported and not enforced | +| foreign_key | 🌗 Supported and not enforced | +| unique | 🌗 Supported and not enforced | +| check | 🌗 Supported and not enforced | From 93705f6e9984ced15cbfaca82ed3400469008200 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Mon, 21 Aug 2023 14:27:04 -0400 Subject: [PATCH 4/7] Updates based on feedback --- .../collaborate/govern/model-contracts.md | 92 ++++++++++--------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index c69f1ae958c..ae2dcc2b015 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -88,78 +88,84 @@ When building a model with a defined contract, dbt will do two things differentl ## Platform constraint support -Select the adapter-specific tab for more info on adapter-specific constraint support across platforms. +Select the adapter-specific tab for more info on adapter-specific constraint support across platforms. Constraints fall into three categories based on support and platform enforcement: + +- **Supported and enforced** — The model won't build if it violates the constraint. +- **Supported and not enforced** — The platform supports specifying the type of constraint, but a model can still build even if it violates it. It's a constraint for metadata purposes only. This is common for modern cloud data warehouses and less common for legacy databases. +- **Not supported and not enforced** — You can't specify the type of constraint for the platform. + + -| Constraint type | Support | -|:----------------|:-------------| -| not_null | 🌕 Supported and enforced | -| primary_key | 🌗 Supported and not enforced | -| foreign_key | 🌗 Supported and not enforced | -| unique | 🌗 Supported and not enforced | -| check | 🌑 Not supported | +| Constraint type | Support | Platform enforcement | +|:----------------|:-------------|:------------------| +| not_null | ✅ Supported | ✅ Enforced | +| primary_key | ✅ Supported | ❌ Not enforced | +| foreign_key | ✅ Supported | ❌ Not enforced | +| unique | ✅ Supported | ❌ Not enforced | +| check | ❌ Not supported | ❌ Not enforced | -| Constraint type | Support | -|:----------------|:-------------| -| not_null | 🌕 Supported and enforced | -| primary_key | 🌗 Supported and not enforced | -| foreign_key | 🌗 Supported and not enforced | -| unique | 🌗 Supported and not enforced | -| check | 🌑 Not supported | +| Constraint type | Support | Platform enforcement | +|:----------------|:-------------|:---------------------| +| not_null | ✅ Supported | ✅ Enforced | +| primary_key | ✅ Supported | ❌ Not enforced | +| foreign_key | ✅ Supported | ❌ Not enforced | +| unique | ✅ Supported | ❌ Not enforced | +| check | ❌ Not supported | ❌ Not enforced | -| Constraint type | Support | -|:-----------------|:-------------| -| not_null | 🌕 Supported and enforced | -| primary_key | 🌕 Supported and enforced | -| foreign_key | 🌕 Supported and enforced | -| unique | 🌑 Not supported | -| check | 🌑 Not supported | +| Constraint type | Support | Platform enforcement | +|:-----------------|:-------------|:---------------------| +| not_null | ✅ Supported | ✅ Enforced | +| primary_key | ✅ Supported | ✅ Enforced | +| foreign_key | ✅ Supported | ✅ Enforced | +| unique | ❌ Not supported | ❌ Not enforced | +| check | ❌ Not supported | ❌ Not enforced | -| Constraint type | Support | -|:----------------|:-------------| -| not_null | 🌕 Supported and enforced | -| primary_key | 🌕 Supported and enforced | -| foreign_key | 🌕 Supported and enforced | -| unique | 🌕 Supported and enforced | -| check | 🌕 Supported and enforced | +| Constraint type | Support | Platform enforcement | +|:----------------|:-------------|:--------------------| +| not_null | ✅ Supported | ✅ Enforced | +| primary_key | ✅ Supported | ✅ Enforced | +| foreign_key | ✅ Supported | ✅ Enforced | +| unique | ✅ Supported | ✅ Enforced | +| check | ✅ Supported | ✅ Enforced | `not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. -| Constraint type | Support | -|:----------------|:------------| -| not_null | 🌗 Supported and not enforced | -| primary_key | 🌗 Supported and not enforced | -| foreign_key | 🌗 Supported and not enforced | -| unique | 🌗 Supported and not enforced | -| check | 🌗 Supported and not enforced | +| Constraint type | Support | Platform enforcement | +|:----------------|:------------|:---------------------| +| not_null | ✅ Supported | ❌ Not enforced | +| primary_key | ✅ Supported | ❌ Not enforced | +| foreign_key | ✅ Supported | ❌ Not enforced | +| unique | ✅ Supported | ❌ Not enforced | +| check | ✅ Supported | ❌ Not enforced | `not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. -| Constraint type | Support | -|:----------------|:------------| -| not_null | 🌗 Supported and not enforced | -| primary_key | 🌗 Supported and not enforced | -| foreign_key | 🌗 Supported and not enforced | -| unique | 🌗 Supported and not enforced | -| check | 🌗 Supported and not enforced | +| Constraint type | Support | Platform enforcement | +|:----------------|:-------------|:---------------------| +| not_null | ✅ Supported | ❌ Not enforced | +| primary_key | ✅ Supported | ❌ Not enforced | +| foreign_key | ✅ Supported | ❌ Not enforced | +| unique | ✅ Supported | ❌ Not enforced | +| check | ✅ Supported | ❌ Not enforced | From 4c3f8ce4ef8fa970eeae4bb7416555d556115d15 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Mon, 21 Aug 2023 15:05:01 -0400 Subject: [PATCH 5/7] Update website/docs/docs/collaborate/govern/model-contracts.md Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com> --- website/docs/docs/collaborate/govern/model-contracts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index ae2dcc2b015..bb36228e6d8 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -88,7 +88,7 @@ When building a model with a defined contract, dbt will do two things differentl ## Platform constraint support -Select the adapter-specific tab for more info on adapter-specific constraint support across platforms. Constraints fall into three categories based on support and platform enforcement: +Select the adapter-specific tab for more information on constraint support across platforms. Constraints fall into three categories based on support and platform enforcement: - **Supported and enforced** — The model won't build if it violates the constraint. - **Supported and not enforced** — The platform supports specifying the type of constraint, but a model can still build even if it violates it. It's a constraint for metadata purposes only. This is common for modern cloud data warehouses and less common for legacy databases. From 2b24edceb82b30736e407bef0b3936613eae4956 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Mon, 21 Aug 2023 15:05:18 -0400 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com> --- website/docs/docs/collaborate/govern/model-contracts.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index bb36228e6d8..1c53b7da738 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -91,7 +91,7 @@ When building a model with a defined contract, dbt will do two things differentl Select the adapter-specific tab for more information on constraint support across platforms. Constraints fall into three categories based on support and platform enforcement: - **Supported and enforced** — The model won't build if it violates the constraint. -- **Supported and not enforced** — The platform supports specifying the type of constraint, but a model can still build even if it violates it. It's a constraint for metadata purposes only. This is common for modern cloud data warehouses and less common for legacy databases. +- **Supported and not enforced** — The platform supports specifying the type of constraint, but a model can still build even if building the model violates the constraint. This constraint exists for metadata purposes only. This is common for modern cloud data warehouses and less common for legacy databases. - **Not supported and not enforced** — You can't specify the type of constraint for the platform. @@ -144,7 +144,7 @@ Select the adapter-specific tab for more information on constraint support acros -`not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. +Currently, `not_null` and `check` constraints are supported and enforced only after a model builds. Because of this platform limitation, dbt considers these constraints `supported` but `not enforced`, which means they're not part of the "model contract" since these constraints can't be enforced at build time. This table will change as the features evolve. | Constraint type | Support | Platform enforcement | |:----------------|:------------|:---------------------| @@ -157,7 +157,7 @@ Select the adapter-specific tab for more information on constraint support acros -`not_null` and `check` constraints are supported and enforced. Currently, constraints are enforced only after a model builds. Because of this platform limitation, the constraints are considered `supported` but `not enforced` and not part of the "model contract" since they can't be enforced at build time. This table will change as the features evolve. +Currently, `not_null` and `check` constraints are supported and enforced only after a model builds. Because of this platform limitation, dbt considers these constraints `supported` but `not enforced`, which means they're not part of the "model contract" since these constraints can't be enforced at build time. This table will change as the features evolve. | Constraint type | Support | Platform enforcement | |:----------------|:-------------|:---------------------| From 17d98d747404e3b8c5edb8e354ec42b6348ed1bc Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Mon, 21 Aug 2023 15:20:13 -0400 Subject: [PATCH 7/7] Update website/docs/docs/collaborate/govern/model-contracts.md --- website/docs/docs/collaborate/govern/model-contracts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/collaborate/govern/model-contracts.md b/website/docs/docs/collaborate/govern/model-contracts.md index 1c53b7da738..380da3c1b72 100644 --- a/website/docs/docs/collaborate/govern/model-contracts.md +++ b/website/docs/docs/collaborate/govern/model-contracts.md @@ -88,7 +88,7 @@ When building a model with a defined contract, dbt will do two things differentl ## Platform constraint support -Select the adapter-specific tab for more information on constraint support across platforms. Constraints fall into three categories based on support and platform enforcement: +Select the adapter-specific tab for more information on [constraint](/reference/resource-properties/constraints) support across platforms. Constraints fall into three categories based on support and platform enforcement: - **Supported and enforced** — The model won't build if it violates the constraint. - **Supported and not enforced** — The platform supports specifying the type of constraint, but a model can still build even if building the model violates the constraint. This constraint exists for metadata purposes only. This is common for modern cloud data warehouses and less common for legacy databases.