From 13831bd86f06d13025913a2cb2d94b0a18ba2d79 Mon Sep 17 00:00:00 2001 From: Evgeniy <7255359+evgeniybobok@users.noreply.github.com> Date: Tue, 31 Oct 2023 04:46:59 +0100 Subject: [PATCH] Added `group` properties to dbt_project.yml files (#94) * Added 'group' property for model_configs in dbt_project.yml * Added group defs and fixed tests for model_configs * All node_types * Added group to seed, snapshot and test_configs * Revert tests changes * add group to resources yml for those that can be grouped * restore 1.6, add groups * typo * turns out semantic models are 1.7+ * add tests * revert groups in default path, as it's used for <1.4 and groups are 1.5+ * make group a ref --------- Co-authored-by: Dave Connors --- schemas/1.5/dbt_project-1.5.json | 33 +++++++++++++++++++++++++++++ schemas/1.5/dbt_yml_files-1.5.json | 19 +++++++++++++++-- schemas/1.6/dbt_project-1.6.json | 27 +++++++++++++++++++++++ schemas/1.6/dbt_yml_files-1.6.json | 17 ++++++++++++++- tests/1.5/valid/dbt_project.yml | 2 ++ tests/1.6/invalid/dbt_yml_files.yml | 5 +++++ tests/1.6/valid/dbt_project.yml | 1 + tests/1.6/valid/dbt_yml_files.yml | 1 + 8 files changed, 102 insertions(+), 3 deletions(-) diff --git a/schemas/1.5/dbt_project-1.5.json b/schemas/1.5/dbt_project-1.5.json index 7cfef1d..f3c500c 100644 --- a/schemas/1.5/dbt_project-1.5.json +++ b/schemas/1.5/dbt_project-1.5.json @@ -238,12 +238,18 @@ "+enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "+group": { + "$ref": "#/$defs/group" + }, "+treat_null_values_as_zero": { "$ref": "#/$defs/boolean_or_jinja_string" }, "enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "group": { + "$ref": "#/$defs/group" + }, "treat_null_values_as_zero": { "$ref": "#/$defs/boolean_or_jinja_string" } @@ -292,6 +298,9 @@ "+grant_access_to": { "$ref": "#/$defs/grant_access_to" }, + "+group": { + "$ref": "#/$defs/group" + }, "+hours_to_expiration": { "$ref": "#/$defs/hours_to_expiration" }, @@ -365,6 +374,9 @@ "grant_access_to": { "$ref": "#/$defs/grant_access_to" }, + "group": { + "$ref": "#/$defs/group" + }, "hours_to_expiration": { "$ref": "#/$defs/hours_to_expiration" }, @@ -451,6 +463,9 @@ "+enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "+group": { + "$ref": "#/$defs/group" + }, "+meta": { "$ref": "#/$defs/meta" }, @@ -481,6 +496,9 @@ "enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "$ref": "#/$defs/meta" }, @@ -536,6 +554,9 @@ "+grants": { "$ref": "#/$defs/grants" }, + "+group": { + "$ref": "#/$defs/group" + }, "+meta": { "$ref": "#/$defs/meta" }, @@ -584,6 +605,9 @@ "grants": { "$ref": "#/$defs/grants" }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "$ref": "#/$defs/meta" }, @@ -696,6 +720,9 @@ "+fail_calc": { "$ref": "#/$defs/fail_calc" }, + "+group": { + "$ref": "#/$defs/group" + }, "+limit": { "$ref": "#/$defs/limit" }, @@ -726,6 +753,9 @@ "fail_calc": { "$ref": "#/$defs/fail_calc" }, + "group": { + "$ref": "#/$defs/group" + }, "limit": { "$ref": "#/$defs/limit" }, @@ -788,6 +818,9 @@ "additionalProperties": false } }, + "group": { + "type": "string" + }, "hours_to_expiration": { "type": "number", "description": "Configuration specific to BigQuery adapter used to set an expiration delay (in hours) to a table." diff --git a/schemas/1.5/dbt_yml_files-1.5.json b/schemas/1.5/dbt_yml_files-1.5.json index 45a6bab..d8a49d8 100644 --- a/schemas/1.5/dbt_yml_files-1.5.json +++ b/schemas/1.5/dbt_yml_files-1.5.json @@ -55,6 +55,9 @@ "type": "boolean" } } + }, + "group": { + "$ref": "#/$defs/group" } } } @@ -219,7 +222,7 @@ "$ref": "#/$defs/boolean_or_jinja_string" }, "group": { - "type": "string" + "$ref": "#/$defs/group" } } }, @@ -254,6 +257,9 @@ "additionalProperties": false } }, + "group": { + "$ref": "#/$defs/group" + }, "label": { "type": "string" }, @@ -326,7 +332,7 @@ } }, "group": { - "type": "string" + "$ref": "#/$defs/group" }, "latest_version": { "type": "number" @@ -421,6 +427,9 @@ } } }, + "group": { + "$ref": "#/$defs/group" + }, "tests": { "type": "array", "items": { @@ -504,6 +513,9 @@ } } }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "type": "object" }, @@ -789,6 +801,9 @@ }, "additionalProperties": false }, + "group": { + "type": "string" + }, "include_exclude": { "type": "object", "properties": { diff --git a/schemas/1.6/dbt_project-1.6.json b/schemas/1.6/dbt_project-1.6.json index 0ef9da2..428c184 100644 --- a/schemas/1.6/dbt_project-1.6.json +++ b/schemas/1.6/dbt_project-1.6.json @@ -260,6 +260,9 @@ "+grant_access_to": { "$ref": "#/$defs/grant_access_to" }, + "+group": { + "$ref": "#/$defs/group" + }, "+hours_to_expiration": { "$ref": "#/$defs/hours_to_expiration" }, @@ -333,6 +336,9 @@ "grant_access_to": { "$ref": "#/$defs/grant_access_to" }, + "group": { + "$ref": "#/$defs/group" + }, "hours_to_expiration": { "$ref": "#/$defs/hours_to_expiration" }, @@ -419,6 +425,9 @@ "+enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "+group": { + "$ref": "#/$defs/group" + }, "+meta": { "$ref": "#/$defs/meta" }, @@ -449,6 +458,9 @@ "enabled": { "$ref": "#/$defs/boolean_or_jinja_string" }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "$ref": "#/$defs/meta" }, @@ -504,6 +516,9 @@ "+grants": { "$ref": "#/$defs/grants" }, + "+group": { + "$ref": "#/$defs/group" + }, "+meta": { "$ref": "#/$defs/meta" }, @@ -552,6 +567,9 @@ "grants": { "$ref": "#/$defs/grants" }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "$ref": "#/$defs/meta" }, @@ -664,6 +682,9 @@ "+fail_calc": { "$ref": "#/$defs/fail_calc" }, + "+group": { + "$ref": "#/$defs/group" + }, "+limit": { "$ref": "#/$defs/limit" }, @@ -694,6 +715,9 @@ "fail_calc": { "$ref": "#/$defs/fail_calc" }, + "group": { + "$ref": "#/$defs/group" + }, "limit": { "$ref": "#/$defs/limit" }, @@ -756,6 +780,9 @@ "additionalProperties": false } }, + "group": { + "type": "string" + }, "hours_to_expiration": { "type": "number", "description": "Configuration specific to BigQuery adapter used to set an expiration delay (in hours) to a table." diff --git a/schemas/1.6/dbt_yml_files-1.6.json b/schemas/1.6/dbt_yml_files-1.6.json index c26f6de..c67e7d5 100644 --- a/schemas/1.6/dbt_yml_files-1.6.json +++ b/schemas/1.6/dbt_yml_files-1.6.json @@ -55,6 +55,9 @@ "type": "boolean" } } + }, + "group": { + "$ref": "#/$defs/group" } } } @@ -196,6 +199,9 @@ "filter": { "type": "string" }, + "group": { + "$ref": "#/$defs/group" + }, "label": { "type": "string" }, @@ -259,7 +265,7 @@ } }, "group": { - "type": "string" + "$ref": "#/$defs/group" }, "latest_version": { "type": "number" @@ -354,6 +360,9 @@ } } }, + "group": { + "$ref": "#/$defs/group" + }, "tests": { "type": "array", "items": { @@ -488,6 +497,9 @@ } } }, + "group": { + "$ref": "#/$defs/group" + }, "meta": { "type": "object" }, @@ -880,6 +892,9 @@ }, "additionalProperties": false }, + "group": { + "type": "string" + }, "include_exclude": { "type": "object", "properties": { diff --git a/tests/1.5/valid/dbt_project.yml b/tests/1.5/valid/dbt_project.yml index 5b9543c..384ec3a 100644 --- a/tests/1.5/valid/dbt_project.yml +++ b/tests/1.5/valid/dbt_project.yml @@ -44,6 +44,7 @@ models: materialized: table empty_subdirectory: another_one: + +group: real meta: owner: Tony contracted_models: @@ -56,6 +57,7 @@ models: jinja_key: "{{ target.name }}" seeds: + +group: sunflower test: +enabled: false empty_subdirectory: diff --git a/tests/1.6/invalid/dbt_yml_files.yml b/tests/1.6/invalid/dbt_yml_files.yml index f82c04a..9f0940a 100644 --- a/tests/1.6/invalid/dbt_yml_files.yml +++ b/tests/1.6/invalid/dbt_yml_files.yml @@ -23,6 +23,11 @@ models: - unique - not_null +semantic_models: + - model: ref('models') + name: model + group: farmhands_only + metrics: - name: new_customers label: New Customers marked 'paying' diff --git a/tests/1.6/valid/dbt_project.yml b/tests/1.6/valid/dbt_project.yml index 13ff230..2e89b0a 100644 --- a/tests/1.6/valid/dbt_project.yml +++ b/tests/1.6/valid/dbt_project.yml @@ -44,6 +44,7 @@ models: materialized: table empty_subdirectory: another_one: + +group: real meta: owner: Tony contracted_models: diff --git a/tests/1.6/valid/dbt_yml_files.yml b/tests/1.6/valid/dbt_yml_files.yml index 7bd16d2..504efd2 100644 --- a/tests/1.6/valid/dbt_yml_files.yml +++ b/tests/1.6/valid/dbt_yml_files.yml @@ -67,6 +67,7 @@ models: snapshots: - name: snapshot_name + group: analytics description: slowly changing dimension columns: - name: id