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

Model contract configs #59

Merged
merged 15 commits into from
Apr 4, 2023
Merged
18 changes: 18 additions & 0 deletions schemas/dbt_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@
"type": "string"
}
},
"contract": {
"type": "object",
"required": [
"enforced"
],
"properties": {
"enforced": {
"$ref": "#/$defs/boolean_or_jinja_string",
"default": "true"
}
}
},
"empty_directory": {
"type": "null"
},
Expand Down Expand Up @@ -254,6 +266,9 @@
"$ref": "#/$defs/boolean_or_jinja_string",
"default": false
},
"+contract": {
"$ref": "#/$defs/contract"
},
"+database": {
"$ref": "#/$defs/database"
},
Expand Down Expand Up @@ -309,6 +324,9 @@
"$ref": "#/$defs/boolean_or_jinja_string",
"default": false
},
"contract": {
"$ref": "#/$defs/contract"
},
"database": {
"$ref": "#/$defs/database"
},
Expand Down
229 changes: 181 additions & 48 deletions schemas/dbt_yml_files.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,32 @@
}
}
},
"groups": {
"type": "array",
"items": {
"type": "object",
"required": ["name", "owner"],
"properties": {
"name": {
"type": "string"
},
"owner": {
"type": "object",
"minProperties": 1,
dave-connors-3 marked this conversation as resolved.
Show resolved Hide resolved
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"macros": {
"type": "array",
"items": {
Expand Down Expand Up @@ -183,6 +209,20 @@
]
},
"properties": {
"config": {
"type": "object",
"properties": {
"enabled": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"treat_null_values_as_zero": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"group": {
"type": "string"
}
}
},
"calculation_method": {
"type": "string"
},
Expand Down Expand Up @@ -246,61 +286,21 @@
"name": {
"type": "string"
},
"access": {
"type": "string",
"enum": ["private", "protected", "public"]
},
"columns": {
"type": "array",
"items": {
"$ref": "#/$defs/column_properties"
}
},
"config": {
"type": "object",
"properties": {
"grant_access_to": {
"title": "Authorized views",
"type": "array",
"description": "Configuration, specific to BigQuery adapter, used to setup authorized views.",
"items": {
"type": "object",
"required": ["database", "project"],
"properties": {
"database": {
"type": "string"
},
"project": {
"type": "string"
}
},
"additionalProperties": false
}
},
"hours_to_expiration": {
"type": "number",
"description": "Configuration specific to BigQuery adapter used to set an expiration delay (in hours) to a table."
},
"kms_key_name": {
"type": "string",
"description": "Configuration of the KMS key name, specific to BigQuery adapter.",
"pattern": "projects/[a-zA-Z0-9_-]*/locations/[a-zA-Z0-9_-]*/keyRings/.*/cryptoKeys/.*"
},
"labels": {
"title": "Label configs",
"type": "object",
"description": "Configuration specific to BigQuery adapter used to add labels and tags to tables/views created by dbt.",
"patternProperties": {
"^[a-z][a-z0-9_-]{0,62}$": {
"type": "string",
"pattern": "^[a-z0-9_-]{0,63}$"
}
},
"additionalProperties": false
},
"materialized": {
"type": "string"
},
"sql_header": {
"type": "string"
}
}
"$ref": "#/$defs/model_configs"
},
"constraints": {
"$ref": "#/$defs/constraints"
},
"description": {
"type": "string"
Expand All @@ -313,6 +313,12 @@
}
}
},
"group": {
"type": "string"
},
"latest_version": {
"type": "number"
},
"meta": {
"type": "object"
},
Expand All @@ -321,6 +327,34 @@
"items": {
"$ref": "#/$defs/tests"
}
},
"versions": {
"type": "array",
"items": {
"type": "object",
"required": ["v"],
"properties": {
"v": {
"type": "number"
},
"config": {
"$ref": "#/$defs/model_configs"
},
"columns": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/$defs/include_exclude"
},
{
"$ref": "#/$defs/column_properties"
}
]
}
}
}
}
}
},
"additionalProperties": false
Expand Down Expand Up @@ -634,6 +668,9 @@
"name": {
"type": "string"
},
"constraints": {
"$ref": "#/$defs/constraints"
},
"data_type": {
"type": "string"
},
Expand Down Expand Up @@ -666,6 +703,33 @@
},
"additionalProperties": false
},
"constraints": {
"type": "array",
"items": {
"type": "object",
"required": ["type"],
"properties": {
"columns": {
"$ref": "#/$defs/string_or_array_of_strings"
},
"expression": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
},
"warn_unenforced": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"warn_unsupported": {
"$ref": "#/$defs/boolean_or_jinja_string"
}
}
}
},
"freshness_definition": {
"default": {
"warn_after": {
Expand Down Expand Up @@ -712,10 +776,79 @@
},
"additionalProperties": false
},
"include_exclude": {
"type": "object",
"properties": {
"include": {
"$ref": "#/$defs/string_or_array_of_strings"
},
"exclude": {
"$ref": "#/$defs/string_or_array_of_strings"
}
}
},
"jinja_string": {
"type": "string",
"pattern": "\\{\\{.*\\}\\}"
},
"model_configs": {
"type": "object",
"properties": {
"contract": {
"type": "object",
"properties": {
"enforced": {
"$ref": "#/$defs/boolean_or_jinja_string"
}
}
},
"grant_access_to": {
"title": "Authorized views",
"type": "array",
"description": "Configuration, specific to BigQuery adapter, used to setup authorized views.",
"items": {
"type": "object",
"required": ["database", "project"],
"properties": {
"database": {
"type": "string"
},
"project": {
"type": "string"
}
},
"additionalProperties": false
}
},
"hours_to_expiration": {
"type": "number",
"description": "Configuration specific to BigQuery adapter used to set an expiration delay (in hours) to a table."
},
"kms_key_name": {
"type": "string",
"description": "Configuration of the KMS key name, specific to BigQuery adapter.",
"pattern": "projects/[a-zA-Z0-9_-]*/locations/[a-zA-Z0-9_-]*/keyRings/.*/cryptoKeys/.*"
},
"labels": {
"title": "Label configs",
"type": "object",
"description": "Configuration specific to BigQuery adapter used to add labels and tags to tables/views created by dbt.",
"patternProperties": {
"^[a-z][a-z0-9_-]{0,62}$": {
"type": "string",
"pattern": "^[a-z0-9_-]{0,63}$"
}
},
"additionalProperties": false
},
"materialized": {
"type": "string"
},
"sql_header": {
"type": "string"
}
}
},
dave-connors-3 marked this conversation as resolved.
Show resolved Hide resolved
"number_or_jinja_string": {
"oneOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions tests/valid/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ models:
# same key without the plus
materialized: table
empty_subdirectory:
contracted_models:
+contract:
enforced: true

test_bq:
+labels:
key: val
Expand Down
Loading