Skip to content

Commit

Permalink
Merge pull request #129 from dbt-labs/saved-queries-exports
Browse files Browse the repository at this point in the history
add saved queries and exports to latest
  • Loading branch information
dave-connors-3 authored May 23, 2024
2 parents d6a8f37 + e444bf5 commit 95c2b82
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 5 deletions.
90 changes: 87 additions & 3 deletions schemas/latest/dbt_yml_files-latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,17 @@
"owner": {
"type": "object",
"anyOf": [
{"required": ["email"]},
{"required": ["name"]}
],
{
"required": [
"email"
]
},
{
"required": [
"name"
]
}
],
"properties": {
"name": {
"type": "string"
Expand Down Expand Up @@ -343,6 +351,51 @@
"additionalProperties": false
}
},
"saved_queries": {
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"description",
"label",
"query_params"
],
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"exports": {
"type": "array",
"items": {
"$ref": "#/$defs/export"
}
},
"label": {
"type": "string"
},
"query_params": {
"type": "object",
"properties": {
"dimensions": {
"$ref": "#/$defs/array_of_strings"
},
"metrics": {
"$ref": "#/$defs/array_of_strings"
},
"where": {
"$ref": "#/$defs/array_of_strings"
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"seeds": {
"type": "array",
"items": {
Expand Down Expand Up @@ -1225,6 +1278,37 @@
},
"additionalProperties": false
},
"export": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
},
"config": {
"type": "object",
"properties": {
"alias": {
"type": "string"
},
"export_as": {
"enum": [
"table",
"view",
"cache"
]
},
"schema": {
"type": "string"
}
},
"additionalProperties": true
}
},
"additionalProperties": false
},
"freshness_definition": {
"default": {
"error_after": {
Expand Down
24 changes: 23 additions & 1 deletion tests/latest/invalid/dbt_yml_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,26 @@ unit_tests:
expect:
rows: |
col_1,col_2
val_1,val_2
val_1,val_2
saved_queries:
- name: test_saved_query
description:
term: paper
label: Test saved query
query_params:
metrics: simple_metric
group_by:
- "Dimension('user__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
alias: my_export_alias
export_as: joel
schema:
- my_export_schema_name
- my_export_schema_name_2}
22 changes: 21 additions & 1 deletion tests/latest/valid/dbt_yml_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,24 @@ metrics:
type_params:
measure: customers_with_orders
filter: |
{{ Dimension('customer__customer_type') }} = 'new'
{{ Dimension('customer__customer_type') }} = 'new'
saved_queries:
- name: test_saved_query
description: "{{ doc('saved_query_description') }}"
label: Test saved query
query_params:
metrics:
- simple_metric
group_by:
- "Dimension('user__ds')"
where:
- "{{ Dimension('user__ds', 'DAY') }} <= now()"
- "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'"
exports:
- name: my_export
config:
alias: my_export_alias
export_as: table
schema: my_export_schema_name

0 comments on commit 95c2b82

Please sign in to comment.