diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb6bc9f..b415e96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,9 @@ name: CI -on: pull_request +on: + - pull_request + - workflow_dispatch + jobs: validate-json-schemas: diff --git a/schemas/dbt_project.json b/schemas/dbt_project.json index a5f2f09..d6da5fb 100644 --- a/schemas/dbt_project.json +++ b/schemas/dbt_project.json @@ -62,10 +62,24 @@ "$ref": "#/$defs/model_configs" }, "on-run-end": { - "$ref": "#/$defs/array_of_strings" + "anyOf": [ + { + "$ref": "#/$defs/array_of_strings" + }, + { + "type": "string" + } + ] }, "on-run-start": { - "$ref": "#/$defs/array_of_strings" + "anyOf": [ + { + "$ref": "#/$defs/array_of_strings" + }, + { + "type": "string" + } + ] }, "packages-install-path": { "type": "string" @@ -95,6 +109,20 @@ } ] }, + "quoting": { + "type": "object", + "properties": { + "database": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "identifier": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "schema": { + "$ref": "#/$defs/boolean_or_jinja_string" + } + } + }, "require-dbt-version": { "$ref": "#/$defs/string_or_array_of_strings" }, @@ -134,11 +162,13 @@ "type": "string" } }, + "empty_directory": { + "type": "null" + }, "boolean_or_jinja_string": { "oneOf": [ { - "type": "string", - "pattern": "\\{\\{.*\\}\\}" + "$ref": "#/$defs/jinja_string" }, { "type": "boolean" @@ -162,14 +192,25 @@ }, "additionalProperties": false }, + "jinja_string": { + "type": "string", + "pattern": "\\{\\{.*\\}\\}" + }, "label_configs": { "title": "Label configs", "type": "object", "description": "Configurations specific to BigQuery adapter used to add labels and tags to tables & views created by dbt.", "patternProperties": { "^[a-z][a-z0-9_-]{0,63}$": { - "type": "string", - "pattern": "^[a-z0-9_-]{0,64}$" + "oneOf": [ + { + "type": "string", + "pattern": "^[a-z0-9_-]{0,64}$" + }, + { + "$ref": "#/$defs/jinja_string" + } + ] } }, "additionalProperties": false @@ -255,7 +296,14 @@ } }, "additionalProperties": { - "$ref": "#/$defs/model_configs" + "oneOf" : [ + { + "$ref": "#/$defs/model_configs" + }, + { + "$ref": "#/$defs/empty_directory" + } + ] } }, "persist_docs_config": { @@ -298,22 +346,86 @@ }, "+tags": { "$ref": "#/$defs/string_or_array_of_strings" + }, + "+column_types": { + "type": "object", + "patternProperties": { + "": { + "type": "string" + } + } + }, + "+full_refresh": { + "$ref": "#/$defs/boolean_or_jinja_string" } }, "additionalProperties": { - "$ref": "#/$defs/seed_configs" + "oneOf" : [ + { + "$ref": "#/$defs/seed_configs" + }, + { + "$ref": "#/$defs/empty_directory" + } + ] } }, "snapshot_configs": { "title": "Snapshot configs", "type": "object", "properties": { + "+alias": { + "type": "string" + }, + "+check_cols": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "+enabled": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "+grants": { + "type": "object" + }, + "+persist_docs": { + "$ref": "#/$defs/persist_docs_config" + }, + "+post-hook": { + "$ref": "#/$defs/array_of_strings" + }, + "+pre-hook": { + "$ref": "#/$defs/array_of_strings" + }, + "+quote_columns": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "+strategy": { + "type": "string" + }, + "+tags": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "+target_database": { + "type": "string" + }, "+target_schema": { "type": "string" + }, + "+unique_key": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "+updated_at": { + "type": "string" } }, "additionalProperties": { - "$ref": "#/$defs/snapshot_configs" + "oneOf" : [ + { + "$ref": "#/$defs/snapshot_configs" + }, + { + "$ref": "#/$defs/empty_directory" + } + ] } }, "source_configs": { @@ -328,7 +440,14 @@ } }, "additionalProperties": { - "$ref": "#/$defs/source_configs" + "oneOf" : [ + { + "$ref": "#/$defs/source_configs" + }, + { + "$ref": "#/$defs/empty_directory" + } + ] } }, "string_or_array_of_strings": { @@ -388,8 +507,15 @@ } }, "additionalProperties": { - "$ref": "#/$defs/test_configs" + "oneOf" : [ + { + "$ref": "#/$defs/test_configs" + }, + { + "$ref": "#/$defs/empty_directory" + } + ] } } } -} \ No newline at end of file +} diff --git a/schemas/dbt_yml_files.json b/schemas/dbt_yml_files.json index 37b3de4..03e869a 100644 --- a/schemas/dbt_yml_files.json +++ b/schemas/dbt_yml_files.json @@ -6,877 +6,908 @@ "version" ], "properties": { - "version": { - "type": "number", - "const": 2 - }, - "analyses": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "columns": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "data_type": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "config": { - "type": "object", - "properties": { - "tags": { - "$ref": "#/$defs/string_or_array_of_strings" - } - }, - "additionalProperties": false - }, - "description": { - "type": "string" - }, - "docs": { - "type": "object", - "required": [ - "show" - ], - "properties": { - "show": { - "type": "boolean" - } - } - } - } - } - }, - "exposures": { - "type": "array", - "items": { - "type": "object", - "required": [ - "depends_on", - "name", - "owner", - "type" - ], - "$comment": "NB: depends_on is not strictly required, but is _expected_ according to the documentation", - "properties": { - "name": { - "type": "string" - }, - "label": { - "type": "string", - "$comment": "Added in dbt Core v1.3" - }, - "type": { - "type": "string", - "enum": [ - "dashboard", - "notebook", - "analysis", - "ml", - "application" - ] - }, - "depends_on": { - "type": "array", - "items": { - "type": "string" - } - }, - "description": { - "type": "string" - }, - "maturity": { - "type": "string", - "enum": [ - "high", - "medium", - "low" - ] - }, - "meta": { - "type": "object" - }, - "owner": { - "type": "object", - "required": [ - "email" - ], - "properties": { - "name": { - "type": "string" - }, - "email": { - "type": "string" - } - }, - "additionalProperties": false - }, - "tags": { - "$ref": "#/$defs/string_or_array_of_strings" - }, - "url": { - "type": "string" - } - } - } - }, - "macros": { - "type": "array", - "items": { + "version": { + "type": "number", + "const": 2 + }, + "analyses": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { "type": "object", - "required": [ - "name" - ], + "required": ["name"], "properties": { - "name": { - "type": "string" - }, - "arguments": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "description": { - "type": "string" - }, - "docs": { - "type": "object", - "properties": { - "show": { - "type": "boolean" - } - } - } + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "data_type": { + "type": "string" + } }, "additionalProperties": false + } + }, + "config": { + "type": "object", + "properties": { + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + } + }, + "additionalProperties": false + }, + "description": { + "type": "string" + }, + "docs": { + "type": "object", + "required": ["show"], + "properties": { + "show": { + "type": "boolean" + } + } } - }, - "metrics": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name", - "type", - "sql", - "timestamp", - "time_grains" - ], - "if": { - "properties": { - "type": { - "const": "expression" - } - } - }, - "then": { - "required": [ - "name", - "type", - "sql", - "timestamp", - "time_grains" - ] - }, - "else": { - "required": [ - "name", - "type", - "sql", - "timestamp", - "time_grains", - "model" - ] + } + } + }, + "exposures": { + "type": "array", + "items": { + "type": "object", + "required": ["depends_on", "name", "owner", "type"], + "$comment": "NB: depends_on is not strictly required, but is _expected_ according to the documentation", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string", + "$comment": "Added in dbt Core v1.3" + }, + "type": { + "type": "string", + "enum": ["dashboard", "notebook", "analysis", "ml", "application"] + }, + "depends_on": { + "type": "array", + "items": { + "type": "string" + } + }, + "description": { + "type": "string" + }, + "maturity": { + "type": "string", + "enum": ["high", "medium", "low"] + }, + "meta": { + "type": "object" + }, + "owner": { + "type": "object", + "required": ["email"], + "properties": { + "name": { + "type": "string" }, - "properties": { - "name": { - "type": "string" - }, - "type": { - "type": "string" - }, - "description": { - "type": "string" - }, - "dimensions": { - "$ref": "#/$defs/array_of_strings" - }, - "filters": { - "type": "array", - "items": { - "type": "object", - "required": [ - "field", - "operator", - "value" - ], - "properties": { - "field": { - "type": "string" - }, - "operator": { - "type": "string" - }, - "value": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "label": { - "type": "string" - }, - "model": { - "type": "string", - "default": "ref('')" - }, - "sql": { - "type": "string" - }, - "time_grains": { - "$ref": "#/$defs/array_of_strings" - }, - "timestamp": { - "type": "string" - } + "email": { + "type": "string" } + }, + "additionalProperties": false + }, + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "url": { + "type": "string" } - }, - "models": { - "type": "array", - "items": { + } + } + }, + "macros": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "arguments": { + "type": "array", + "items": { "type": "object", - "required": [ - "name" - ], + "required": ["name"], "properties": { - "name": { - "type": "string" - }, - "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,63}$": { - "type": "string", - "pattern": "^[a-z0-9_-]{0,64}$" - } - }, - "additionalProperties": false - }, - "materialized": { - "type": "string" - }, - "sql_header": { - "type": "string" - } - } - }, - "description": { - "type": "string" - }, - "docs": { - "type": "object", - "properties": { - "show": { - "type": "boolean" - } - } - }, - "meta": { - "type": "object" - }, - "tests": { - "type": "array", - "items": { - "$ref": "#/$defs/tests" - } - } + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "description": { + "type": "string" + } }, "additionalProperties": false + } + }, + "description": { + "type": "string" + }, + "docs": { + "type": "object", + "properties": { + "show": { + "type": "boolean" + } + } } - }, - "seeds": { - "type": "array", - "items": { + }, + "additionalProperties": false + } + }, + "metrics": { + "type": "array", + "items": { + "type": "object", + "required": ["name", "type", "sql", "timestamp", "time_grains"], + "if": { + "properties": { + "type": { + "const": "expression" + } + } + }, + "then": { + "required": ["name", "type", "sql", "timestamp", "time_grains"] + }, + "else": { + "required": [ + "name", + "type", + "sql", + "timestamp", + "time_grains", + "model" + ] + }, + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "description": { + "type": "string" + }, + "dimensions": { + "$ref": "#/$defs/array_of_strings" + }, + "filters": { + "type": "array", + "items": { "type": "object", - "required": [ - "name" - ], + "required": ["field", "operator", "value"], "properties": { - "name": { - "type": "string" - }, - "columns": { - "type": "array", - "items": { - "$ref": "#/$defs/column_properties" - } - }, - "config": { - "type": "object", - "properties": { - "column_types": { - "type": "object" - }, - "copy_grants": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "database": { - "type": "string" - }, - "enabled": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "quote_columns": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "schema": { - "type": "string" - } - } - }, - "description": { - "type": "string" - }, - "docs": { - "type": "object", - "properties": { - "show": { - "type": "boolean" - } - } - }, - "tests": { - "type": "array", - "items": { - "$ref": "#/$defs/tests" - } - } + "field": { + "type": "string" + }, + "operator": { + "type": "string" + }, + "value": { + "type": "string" + } }, "additionalProperties": false + } + }, + "label": { + "type": "string" + }, + "model": { + "type": "string", + "default": "ref('')" + }, + "sql": { + "type": "string" + }, + "time_grains": { + "$ref": "#/$defs/array_of_strings" + }, + "timestamp": { + "type": "string" } - }, - "sources": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string", - "description": "How you will identify the schema in {{ source() }} calls. Unless `schema` is also set, this will be the name of the schema in the database." - }, - "config": { - "type": "object" - }, - "database": { - "type": "string" - }, - "description": { - "type": "string" - }, - "freshness": { - "$ref": "#/$defs/freshness_definition" - }, - "loaded_at_field": { + } + } + }, + "models": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "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" - }, - "loader": { + }, + "project": { "type": "string" + } }, - "meta": { - "type": "object" - }, - "overrides": { - "title": "Package to Override", - "type": "string", - "description": "The name of another package installed in your project. If that package has a source with the same name as this one, its properties will be applied on top of the base properties of the overridden source. https://docs.getdbt.com/reference/resource-properties/overrides" - }, - "quoting": { - "type": "object", - "properties": { - "database": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "identifier": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "schema": { - "$ref": "#/$defs/boolean_or_jinja_string" - } - }, - "additionalProperties": false - }, - "schema": { - "type": "string", - "description": "The schema name as stored in the database. Only needed if you want to use a different `name` than what exists in the database (otherwise `name` is used by default)" - }, - "tables": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "title": "Name", - "type": "string", - "description": "How you will identify the table in {{ source() }} calls. Unless `identifier` is also set, this will be the name of the table in the database." - }, - "columns": { - "type": "array", - "items": { - "$ref": "#/$defs/column_properties" - } - }, - "description": { - "type": "string" - }, - "external": { - "type": "object" - }, - "freshness": { - "$ref": "#/$defs/freshness_definition" - }, - "identifier": { - "title": "Identifier", - "type": "string", - "description": "The table name as stored in the database. Only needed if you want to give the source a different name than what exists in the database (otherwise `name` is used by default)" - }, - "loaded_at_field": { - "type": "string", - "description": "Which column to check during data freshness tests. Only needed if the table has a different loaded_at_field to the one defined on the source overall." - }, - "loader": { - "type": "string" - }, - "meta": { - "type": "object" - }, - "quoting": { - "type": "object", - "properties": { - "database": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "identifier": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "schema": { - "$ref": "#/$defs/boolean_or_jinja_string" - } - }, - "additionalProperties": false - }, - "tags": { - "$ref": "#/$defs/string_or_array_of_strings" - }, - "tests": { - "type": "array", - "items": { - "$ref": "#/$defs/tests" - } - } - }, - "additionalProperties": false - } - }, - "tags": { - "$ref": "#/$defs/string_or_array_of_strings" - }, - "tests": { - "type": "array", - "items": { - "$ref": "#/$defs/tests" - } + "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,63}$": { + "type": "string", + "pattern": "^[a-z0-9_-]{0,64}$" } + }, + "additionalProperties": false + }, + "materialized": { + "type": "string" + }, + "sql_header": { + "type": "string" + } + } + }, + "description": { + "type": "string" + }, + "docs": { + "type": "object", + "properties": { + "show": { + "type": "boolean" } + } + }, + "meta": { + "type": "object" + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } } + }, + "additionalProperties": false } - }, - "additionalProperties": false, - "$defs": { - "array_of_strings": { - "type": "array", - "items": { - "type": "string" - } - }, - "boolean_or_jinja_string": { - "oneOf": [ - { - "$ref": "#/$defs/jinja_string" + }, + "seeds": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "$ref": "#/$defs/column_properties" + } + }, + "config": { + "type": "object", + "properties": { + "column_types": { + "type": "object" }, - { - "type": "boolean" + "copy_grants": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "database": { + "type": "string" + }, + "enabled": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "quote_columns": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "schema": { + "type": "string" } - ], - "additionalProperties": false - }, - "column_properties": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { + } + }, + "description": { + "type": "string" + }, + "docs": { + "type": "object", + "properties": { + "show": { + "type": "boolean" + } + } + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } + } + }, + "additionalProperties": false + } + }, + "snapshots": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "$ref": "#/$defs/column_properties" + } + }, + "config": { + "type": "object", + "properties": { + "alias": { "type": "string" }, - "data_type": { - "type": "string" + "check_cols": { + "$ref": "#/$defs/string_or_array_of_strings" }, - "description": { - "type": "string" + "enabled": { + "$ref": "#/$defs/boolean_or_jinja_string" }, - "meta": { + "grants": { "type": "object" }, - "policy_tags": { - "title": "Policy tags", - "type": "array", - "description": "Configurations, specific to BigQuery adapter, used to set policy tags on specific columns, enabling column-level security. Only relevant when `persist_docs.columns` is true.", - "items": { - "type": "string" - } + "persist_docs": { + "$ref": "#/$defs/persist_docs_config" + }, + "post-hook": { + "$ref": "#/$defs/array_of_strings" }, - "quote": { + "pre-hook": { + "$ref": "#/$defs/array_of_strings" + }, + "quote_columns": { "$ref": "#/$defs/boolean_or_jinja_string" }, - "tests": { - "type": "array", - "items": { - "$ref": "#/$defs/tests" - } + "strategy": { + "type": "string" }, "tags": { "$ref": "#/$defs/string_or_array_of_strings" + }, + "target_database": { + "type": "string" + }, + "target_schema": { + "type": "string" + }, + "unique_key": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "updated_at": { + "type": "string" } + } }, - "additionalProperties": false - }, - "freshness_definition": { - "default": { - "warn_after": { - "count": 1, - "period": "day" + "description": { + "type": "string" + }, + "docs": { + "type": "object", + "properties": { + "show": { + "type": "boolean" + } + } + }, + "meta": { + "type": "object" + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } + } + }, + "additionalProperties": false + } + }, + "sources": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string", + "description": "How you will identify the schema in {{ source() }} calls. Unless `schema` is also set, this will be the name of the schema in the database." + }, + "config": { + "type": "object" + }, + "database": { + "type": "string" + }, + "description": { + "type": "string" + }, + "freshness": { + "$ref": "#/$defs/freshness_definition" + }, + "loaded_at_field": { + "type": "string" + }, + "loader": { + "type": "string" + }, + "meta": { + "type": "object" + }, + "overrides": { + "title": "Package to Override", + "type": "string", + "description": "The name of another package installed in your project. If that package has a source with the same name as this one, its properties will be applied on top of the base properties of the overridden source. https://docs.getdbt.com/reference/resource-properties/overrides" + }, + "quoting": { + "type": "object", + "properties": { + "database": { + "$ref": "#/$defs/boolean_or_jinja_string" }, - "error_after": { - "count": 2, - "period": "day" + "identifier": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "schema": { + "$ref": "#/$defs/boolean_or_jinja_string" } + }, + "additionalProperties": false + }, + "schema": { + "type": "string", + "description": "The schema name as stored in the database. Only needed if you want to use a different `name` than what exists in the database (otherwise `name` is used by default)" }, - "oneOf": [ - { + "tables": { + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "How you will identify the table in {{ source() }} calls. Unless `identifier` is also set, this will be the name of the table in the database." + }, + "columns": { + "type": "array", + "items": { + "$ref": "#/$defs/column_properties" + } + }, + "description": { + "type": "string" + }, + "external": { + "type": "object" + }, + "freshness": { + "$ref": "#/$defs/freshness_definition" + }, + "identifier": { + "title": "Identifier", + "type": "string", + "description": "The table name as stored in the database. Only needed if you want to give the source a different name than what exists in the database (otherwise `name` is used by default)" + }, + "loaded_at_field": { + "type": "string", + "description": "Which column to check during data freshness tests. Only needed if the table has a different loaded_at_field to the one defined on the source overall." + }, + "loader": { + "type": "string" + }, + "meta": { + "type": "object" + }, + "quoting": { "type": "object", "properties": { - "error_after": { - "$ref": "#/$defs/freshness_rules" - }, - "filter": { - "type": "string" - }, - "warn_after": { - "$ref": "#/$defs/freshness_rules" - } + "database": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "identifier": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "schema": { + "$ref": "#/$defs/boolean_or_jinja_string" + } }, "additionalProperties": false + }, + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } + } }, - { - "const": null - } - ] + "additionalProperties": false + } + }, + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } + } + } + } + } + }, + "additionalProperties": false, + "$defs": { + "array_of_strings": { + "type": "array", + "items": { + "type": "string" + } + }, + "boolean_or_jinja_string": { + "oneOf": [ + { + "$ref": "#/$defs/jinja_string" + }, + { + "type": "boolean" + } + ], + "additionalProperties": false + }, + "column_properties": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + }, + "data_type": { + "type": "string" + }, + "description": { + "type": "string" + }, + "meta": { + "type": "object" + }, + "policy_tags": { + "title": "Policy tags", + "type": "array", + "description": "Configurations, specific to BigQuery adapter, used to set policy tags on specific columns, enabling column-level security. Only relevant when `persist_docs.columns` is true.", + "items": { + "type": "string" + } + }, + "quote": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "tests": { + "type": "array", + "items": { + "$ref": "#/$defs/tests" + } + }, + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + } + }, + "additionalProperties": false + }, + "freshness_definition": { + "default": { + "warn_after": { + "count": 1, + "period": "day" + }, + "error_after": { + "count": 2, + "period": "day" + } }, - "freshness_rules": { + "oneOf": [ + { "type": "object", - "required": [ - "count", - "period" - ], "properties": { - "count": { - "$ref": "#/$defs/number_or_jinja_string" - }, - "period": { - "type": "string", - "enum": [ - "minute", - "hour", - "day" - ] - } + "error_after": { + "$ref": "#/$defs/freshness_rules" + }, + "filter": { + "type": "string" + }, + "warn_after": { + "$ref": "#/$defs/freshness_rules" + } }, "additionalProperties": false - }, - "jinja_string": { + }, + { + "const": null + } + ] + }, + "freshness_rules": { + "type": "object", + "required": ["count", "period"], + "properties": { + "count": { + "$ref": "#/$defs/number_or_jinja_string" + }, + "period": { "type": "string", - "pattern": "\\{\\{.*\\}\\}" - }, - "number_or_jinja_string": { - "oneOf": [ - { - "$ref": "#/$defs/jinja_string" - }, - { - "type": "number" - } - ], - "additionalProperties": false + "enum": ["minute", "hour", "day"] + } }, - "string_or_array_of_strings": { - "oneOf": [ - { - "type": "string" - }, - { - "$ref": "#/$defs/array_of_strings" - } - ] + "additionalProperties": false + }, + "jinja_string": { + "type": "string", + "pattern": "\\{\\{.*\\}\\}" + }, + "number_or_jinja_string": { + "oneOf": [ + { + "$ref": "#/$defs/jinja_string" + }, + { + "type": "number" + } + ], + "additionalProperties": false + }, + "persist_docs_config": { + "title": "Persist docs config", + "type": "object", + "description": "Configurations for the persistence of the dbt documentation.", + "properties": { + "columns": { + "$ref": "#/$defs/boolean_or_jinja_string", + "default": true + }, + "relation": { + "$ref": "#/$defs/boolean_or_jinja_string", + "default": true + } }, - "test_configs": { - "title": "Test configs", + "additionalProperties": false + }, + "string_or_array_of_strings": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/$defs/array_of_strings" + } + ] + }, + "test_configs": { + "title": "Test configs", + "type": "object", + "description": "Configurations set here will override configs set in dbt_project.yml.", + "properties": { + "alias": { + "type": "string", + "description": "Only relevant when `store_failures` is true" + }, + "database": { + "type": "string", + "description": "Only relevant when `store_failures` is true" + }, + "enabled": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "error_if": { + "type": "string" + }, + "fail_calc": { + "type": "string" + }, + "limit": { + "type": "number" + }, + "schema": { + "type": "string", + "description": "Only relevant when `store_failures` is true" + }, + "severity": { + "type": "string", + "enum": ["warn", "error"] + }, + "store_failures": { + "$ref": "#/$defs/boolean_or_jinja_string" + }, + "tags": { + "$ref": "#/$defs/string_or_array_of_strings" + }, + "warn_if": { + "type": "string" + } + } + }, + "tests": { + "anyOf": [ + { + "type": "string" + }, + { + "title": "Relationships Test", "type": "object", - "description": "Configurations set here will override configs set in dbt_project.yml.", "properties": { - "alias": { - "type": "string", - "description": "Only relevant when `store_failures` is true" - }, - "database": { - "type": "string", - "description": "Only relevant when `store_failures` is true" - }, - "enabled": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "error_if": { - "type": "string" - }, - "fail_calc": { + "relationships": { + "type": "object", + "required": ["to", "field"], + "properties": { + "name": { "type": "string" - }, - "limit": { - "type": "number" - }, - "schema": { + }, + "config": { + "$ref": "#/$defs/test_configs" + }, + "field": { + "title": "Relationships: Field", "type": "string", - "description": "Only relevant when `store_failures` is true" - }, - "severity": { + "default": "", + "description": "The foreign key column" + }, + "to": { "type": "string", - "enum": [ - "warn", - "error" + "default": "ref('')", + "examples": [ + "ref('parent_model')", + "source('parent_schema', 'parent_table')" ] - }, - "store_failures": { - "$ref": "#/$defs/boolean_or_jinja_string" - }, - "tags": { - "$ref": "#/$defs/string_or_array_of_strings" - }, - "warn_if": { + }, + "where": { "type": "string" + } } + } } - }, - "tests": { - "anyOf": [ - { + }, + { + "title": "Accepted Values Test", + "type": "object", + "properties": { + "accepted_values": { + "type": "object", + "required": ["values"], + "properties": { + "name": { "type": "string" - }, - { - "title": "Relationships Test", - "type": "object", - "properties": { - "relationships": { - "type": "object", - "required": [ - "to", - "field" - ], - "properties": { - "name": { - "type": "string" - }, - "config": { - "$ref": "#/$defs/test_configs" - }, - "field": { - "title": "Relationships: Field", - "type": "string", - "default": "", - "description": "The foreign key column" - }, - "to": { - "type": "string", - "default": "ref('')", - "examples": [ - "ref('parent_model')", - "source('parent_schema', 'parent_table')" - ] - }, - "where": { - "type": "string" - } - } - } - } - }, - { - "title": "Accepted Values Test", - "type": "object", - "properties": { - "accepted_values": { - "type": "object", - "required": [ - "values" - ], - "properties": { - "name": { - "type": "string" - }, - "config": { - "$ref": "#/$defs/test_configs" - }, - "quote": { - "type": "boolean" - }, - "values": { - "type": "array", - "items": { - "type": "string" - } - }, - "where": { - "type": "string" - } - } - } - } - }, - { - "title": "Not Null Test", - "type": "object", - "properties": { - "not_null": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "config": { - "$ref": "#/$defs/test_configs" - }, - "where": { - "type": "string" - } - } - } - } - }, - { - "title": "Unique Test", - "type": "object", - "properties": { - "unique": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "config": { - "$ref": "#/$defs/test_configs" - }, - "where": { - "type": "string" - } - } - } + }, + "config": { + "$ref": "#/$defs/test_configs" + }, + "quote": { + "type": "boolean" + }, + "values": { + "type": "array", + "items": { + "type": "string" } + }, + "where": { + "type": "string" + } } - ] - } + } + } + }, + { + "title": "Not Null Test", + "type": "object", + "properties": { + "not_null": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "config": { + "$ref": "#/$defs/test_configs" + }, + "where": { + "type": "string" + } + } + } + } + }, + { + "title": "Unique Test", + "type": "object", + "properties": { + "unique": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "config": { + "$ref": "#/$defs/test_configs" + }, + "where": { + "type": "string" + } + } + } + } + } + ] + } } } diff --git a/tests/valid/dbt_project.yml b/tests/valid/dbt_project.yml index 235747b..bfaccaf 100644 --- a/tests/valid/dbt_project.yml +++ b/tests/valid/dbt_project.yml @@ -37,7 +37,39 @@ models: # Config indicated by + and applies to all files under models/example/ example: +materialized: view + subdirectory: + +materialized: table + empty_subdirectory: + test_bq: + +labels: + key: val + jinja_key: "{{ target.name }}" seeds: test: +enabled: false + empty_subdirectory: + +tests: + test: + +enabled: true + empty_subdirectory: + +snapshots: + test: + +target_schema: schema + +target_database: database + +grants: + select: ['role'] + + empty_subdirectory: + +sources: + test: + +enabled: true + empty_subdirectory: + +quoting: + database: true + schema: true + identifier: true diff --git a/tests/valid/schema.yml b/tests/valid/schema.yml index aeb5214..c60a2e0 100644 --- a/tests/valid/schema.yml +++ b/tests/valid/schema.yml @@ -20,3 +20,11 @@ models: tests: - unique - not_null + + +snapshots: + - name: snapshot_name + description: slowly changing dimension + columns: + - name: id + description: cool column, eh? \ No newline at end of file