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

add saved queries and exports to latest #129

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth checking with a regex match for {{ Dimension for a lot of these, because it feels like a common mistake mode to just provide the name of the dim without the wrapper. (related)

},
"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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaks autocomplete or something? So i lean towards being false and we keep up to date. Without evidence, it's a weak opinion weakly held.

}
},
"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
Loading