Skip to content

Commit

Permalink
Materialized view updates (#111)
Browse files Browse the repository at this point in the history
* Add on_configuration_change to 1.6 files

* Add auto_refresh, backup, target_lag and snowflake_wh

* Add tests
  • Loading branch information
joellabes authored Dec 13, 2023
1 parent b7426eb commit 3b73230
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 6 deletions.
53 changes: 50 additions & 3 deletions schemas/1.6/dbt_project-1.6.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
"type": "string"
}
},
"auto_refresh":{
"$ref": "#/$defs/boolean_or_jinja_string"
},
"backup":{
"$ref": "#/$defs/boolean_or_jinja_string"
},
"contract": {
"type": "object",
"required": ["enforced"],
Expand Down Expand Up @@ -238,6 +244,12 @@
"+alias": {
"$ref": "#/$defs/alias"
},
"+auto_refresh":{
"$ref": "#/$defs/auto_refresh"
},
"+backup":{
"$ref": "#/$defs/backup"
},
"+bind": {
"$ref": "#/$defs/boolean_or_jinja_string",
"default": false
Expand Down Expand Up @@ -289,6 +301,9 @@
},
"+meta": {
"$ref": "#/$defs/meta"
},
"+on_configuration_change": {
"$ref": "#/$defs/on_configuration_change"
},
"+on_schema_change": {
"$ref": "#/$defs/on_schema_change"
Expand All @@ -308,15 +323,27 @@
"+sql_header": {
"$ref": "#/$defs/sql_header"
},
"+snowflake_warehouse":{
"$ref": "#/$defs/snowflake_warehouse"
},
"+tags": {
"$ref": "#/$defs/string_or_array_of_strings"
},
"+target_lag":{
"$ref": "#/$defs/target_lag"
},
"+transient": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"alias": {
"$ref": "#/$defs/alias"
},
"auto_refresh":{
"$ref": "#/$defs/auto_refresh"
},
"backup":{
"$ref": "#/$defs/backup"
},
"bind": {
"$ref": "#/$defs/boolean_or_jinja_string",
"default": false
Expand Down Expand Up @@ -368,6 +395,9 @@
},
"meta": {
"$ref": "#/$defs/meta"
},
"on_configuration_change": {
"$ref": "#/$defs/on_configuration_change"
},
"on_schema_change": {
"$ref": "#/$defs/on_schema_change"
Expand All @@ -384,12 +414,18 @@
"schema": {
"$ref": "#/$defs/schema"
},
"snowflake_warehouse": {
"$ref": "#/$defs/snowflake_warehouse"
},
"sql_header": {
"$ref": "#/$defs/sql_header"
},
"tags": {
"$ref": "#/$defs/string_or_array_of_strings"
},
"target_lag": {
"$ref": "#/$defs/target_lag"
},
"transient": {
"$ref": "#/$defs/boolean_or_jinja_string"
}
Expand Down Expand Up @@ -831,13 +867,17 @@
"materialized": {
"type": "string"
},
"meta": {
"type": "object"
},
"on_configuration_change": {
"type": "string",
"enum": ["apply", "continue", "fail"]
},
"on_schema_change": {
"type": "string",
"enum": ["append_new_columns", "fail", "ignore", "sync_all_columns"]
},
"meta": {
"type": "object"
},
"schema": {
"type": ["string", "null"]
},
Expand All @@ -855,12 +895,19 @@
"alias": {
"type": "string"
},
"snowflake_warehouse": {
"type": "string"
},
"strategy": {
"type": "string"
},
"target_database": {
"type": "string"
},
"target_lag": {
"type": "string",
"pattern": "^(?:downstream|\\d+\\s*(?:seconds|minutes|hours|days))$"
},
"target_schema": {
"type": "string"
},
Expand Down
21 changes: 21 additions & 0 deletions schemas/1.6/dbt_yml_files-1.6.json
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,12 @@
"model_configs": {
"type": "object",
"properties": {
"auto_refresh": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"backup": {
"$ref": "#/$defs/boolean_or_jinja_string"
},
"contract": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1111,9 +1117,24 @@
},
"materialized": {
"type": "string"
},
"on_configuration_change": {
"type": "string",
"enum": ["apply", "continue", "fail"]
},
"on_schema_change": {
"type": "string",
"enum": ["append_new_columns", "fail", "ignore", "sync_all_columns"]
},
"sql_header": {
"type": "string"
},
"snowflake_warehouse":{
"type": "string"
},
"target_lag":{
"type": "string",
"pattern": "^(?:downstream|\\d+\\s*(?:seconds|minutes|hours|days))$"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion tests/1.6/invalid/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ models:
+grants:
no_numbers: 55


materialized_views:
materialized: materialized_view
config:
target_lag: 1 hour
snowflake_warehouse: 11


seeds:
Expand Down
6 changes: 6 additions & 0 deletions tests/1.6/valid/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ models:
+grants:
privilege: role
privileges: ["select_user", "select_cruiser"]
materialized_views:
+materialized: materialized_view
+auto_refresh: true
+backup: '{{ target.name == "prod" }}'
+target_lag: 20 minutes
+snowflake_warehouse: my_warehouse

test_bq:
+labels:
Expand Down
11 changes: 9 additions & 2 deletions tests/1.6/valid/dbt_yml_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ models:
- v: 1
config:
alias: dim_customers

- name: my_model_level_contract_model
config:
contract:
Expand All @@ -70,7 +70,14 @@ models:
- type: unique
columns: [ color, date_day ]
name: strange_uniqueness_requirement


- name: my_materialized_view
config:
materialized: materialized_view
auto_refresh: true
backup: '{{ target.name == "prod" }}'
target_lag: downstream
snowflake_warehouse: my_warehouse

snapshots:
- name: snapshot_name
Expand Down

0 comments on commit 3b73230

Please sign in to comment.