Skip to content

Commit

Permalink
update to saved queries
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Dec 11, 2024
1 parent 16faf8c commit e2ccfb3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 49 deletions.
14 changes: 7 additions & 7 deletions website/docs/docs/build/saved-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Note that we use the double colon (::) to indicate whether a parameter is nested
| `name` | String | Required | Name of the saved query object. |
| `description` | String | Required | A description of the saved query. |
| `label` | String | Required | The display name for your saved query. This value will be shown in downstream tools. |
| `config` | String | Optional | Use the [`config`](/reference/resource-properties/config) property to specify configurations for your saved query. Supports `cache`, [`enabled`](/reference/resource-configs/enabled), `export_as`, [`group`](/reference/resource-configs/group), [`meta`](/reference/resource-configs/meta), and [`schema`](/reference/resource-configs/schema) configurations. |
| `config` | String | Optional | Use the [`config`](/reference/resource-properties/config) property to specify configurations for your saved query. Supports `cache`, [`enabled`](/reference/resource-configs/enabled), `export_as`, [`group`](/reference/resource-configs/group), [`meta`](/reference/resource-configs/meta), [`tags`](/reference/resource-configs/tags), and [`schema`](/reference/resource-configs/schema) configurations. |
| `config::cache::enabled` | Object | Optional | An object with a sub-key used to specify if a saved query should populate the [cache](/docs/use-dbt-semantic-layer/sl-cache). Accepts sub-key `true` or `false`. Defaults to `false` |
| `query_params` | Structure | Required | Contains the query parameters. |
| `query_params::metrics` | List or String | Optional | A list of the metrics to be used in the query as specified in the command line interface. |
Expand All @@ -38,7 +38,6 @@ Note that we use the double colon (::) to indicate whether a parameter is nested
| `exports::config::export_as` | String | Required | The type of export to run. Options include table or view currently and cache in the near future. |
| `exports::config::schema` | String | Optional | The [schema](/reference/resource-configs/schema) for creating the table or view. This option cannot be used for caching. |
| `exports::config::alias` | String | Optional | The table [alias](/reference/resource-configs/alias) used to write to the table or view. This option cannot be used for caching. |
| `exports::config::tags` | String | Optional | Apply a [tag](/reference/resource-configs/tags) (or list of tags) to a resource. Tags help organize and filter resources in dbt. Nested within `exports` and `config`. |

</VersionBlock>

Expand Down Expand Up @@ -108,7 +107,8 @@ saved_queries:
label: Test saved query
config:
cache:
enabled: true # Or false if you want it disabled by default
[enabled](/reference/resource-configs/enabled): true | false
[tags](/reference/resource-configs/tags): 'my_tag'
query_params:
metrics:
- simple_metric
Expand All @@ -123,7 +123,6 @@ saved_queries:
export_as: table
alias: my_export_alias
schema: my_export_schema_name
tags: 'my_tag'
```
</VersionBlock>
Expand Down Expand Up @@ -243,6 +242,9 @@ The following is an example of a saved query with an export:
saved_queries:
- name: order_metrics
description: Relevant order metrics
config:
tags:
- order_metrics
query_params:
metrics:
- orders
Expand All @@ -262,9 +264,7 @@ saved_queries:
config:
export_as: table # Options available: table, view
[alias](/reference/resource-configs/alias): my_export_alias # Optional - defaults to Export name
[schema](/reference/resource-configs/schema): my_export_schema_name # Optional - defaults to deployment schema
[tags](/reference/resource-configs/tags): 'my_tag'
[schema](/reference/resource-configs/schema): my_export_schema_name # Optional - defaults to deployment schema
```
</VersionBlock>

Expand Down
12 changes: 7 additions & 5 deletions website/docs/docs/dbt-versions/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ Release notes are grouped by month for both multi-tenant and virtual private clo

## December 2024

- **New**: Exports now support [tags](/reference/resource-configs/tags) in dbt. Tags allow you to categorize your resources and filter them. You can add tags to your [exports](/docs/build/saved-queries#configure-exports) in the `semantic_model.yml` file or `dbt_project.yml` file. For example:
- **New**: Saved queries now support [tags](/reference/resource-configs/tags), which allow you to categorize your resources and filter them. Add tags to your [saved queries](/docs/build/saved-queries) in the `semantic_model.yml` file or `dbt_project.yml` file. For example:
<File name='dbt_project.yml'>

```yml
exports:
- name: export_name
tags: ['export_tag']
...
[saved-queries](/docs/build/saved-queries):
jaffle_shop:
customer_order_metrics:
+tags: order_metrics
```
</File>
- **New**: [Model notifications](/docs/deploy/model-notifications) are now generally available in dbt Cloud. These notifications alert model owners through email about any issues encountered by models and tests as soon as they occur while running a job.
- **New**: You can now use your [Azure OpenAI key](/docs/cloud/account-integrations?ai-integration=azure#ai-integrations) (available in beta) to use dbt Cloud features like [dbt Copilot](/docs/cloud/dbt-copilot) and [Ask dbt](/docs/cloud-integrations/snowflake-native-app) . Additionally, you can use your own [OpenAI API key](/docs/cloud/account-integrations?ai-integration=openai#ai-integrations) or use [dbt Labs-managed OpenAI](/docs/cloud/account-integrations?ai-integration=dbtlabs#ai-integrations) key. Refer to [AI integrations](/docs/cloud/account-integrations#ai-integrations) for more information.
- **New**: The [`hard_deletes`](/reference/resource-configs/hard-deletes) config gives you more control on how to handle deleted rows from the source. Supported options are `ignore` (default), `invalidate` (replaces the legacy `invalidate_hard_deletes=true`), and `new_record`. Note that `new_record` will create a new metadata column in the snapshot table.
Expand Down
77 changes: 40 additions & 37 deletions website/docs/reference/resource-configs/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ datatype: string | [string]

```yml

models:
[models](/reference/model-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

snapshots:
[snapshots](/reference/snapshot-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

seeds:
[seeds](/reference/seed-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

Expand All @@ -39,19 +39,19 @@ seeds:

```yml

models:
[models](/reference/model-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

snapshots:
[snapshots](/reference/snapshot-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

seeds:
[seeds](/reference/seed-configs):
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

exports:
[saved-queries:](/docs/build/saved-queries)
[<resource-path>](/reference/resource-configs/resource-path):
+tags: <string> | [<string>]

Expand All @@ -64,38 +64,45 @@ exports:

<TabItem value="other-yaml">

<File name='models/resources.yml'>
<VersionBlock firstVersion="1.9">

```yml
version: 2
The following examples show how to add tags to dbt resources in YAML files. Replace `resource_type` with `models`, `snapshots`, `seeds`, or `saved_queries` as appropriate.
</VersionBlock>

models:
- name: model_name
config:
tags: <string> | [<string>]
<VersionBlock lastVersion="1.8">

The following examples show how to add tags to dbt resources in YAML files. Replace `resource_type` with `models`, `snapshots`, or `seeds` as appropriate.
</VersionBlock>

<File name='resource_type/properties.yml'>

```yaml
resource_type:
- name: resource_name
config:
tags: string
# Optional: Add specific properties for models
columns:
- name: column_name
tags: [<string>]
tags: string
tests:
<test-name>:
test-name:
config:
tags: <string> | [<string>]
tags: string
```
</File>
</TabItem>
<TabItem value="config">
```jinja

<File name='models/model.sql'>
```sql
{{ config(
tags="<string>" | ["<string>"]
) }}

```
</File>

</TabItem>

Expand Down Expand Up @@ -191,46 +198,42 @@ seeds:
</File>
### Apply tags to exports
### Apply tags to saved queries
<VersionBlock lastVersion="1.8">
Applying tags to exports is only available in dbt Core versions 1.9 and later.
Applying tags to saved queries is only available in dbt Core versions 1.9 and later.
</VersionBlock>
<VersionBlock firstVersion="1.9">
This following example shows how to apply tags to an export in the `dbt_project.yml` file. The export is then tagged with `order_metrics`.
This following example shows how to apply a tag to a saved query in the `dbt_project.yml` file. The saved query is then tagged with `order_metrics`.

<File name='dbt_project.yml'>

```yml
[exports](/docs/build/saved-queries#configure-exports):
[saved-queries](/docs/build/saved-queries):
jaffle_shop:
customer_order_metrics:
+tags: order_metrics
```

</File>

The second example shows how to apply tags to an export in the `semantic_model.yml` file. The export is then tagged with `order_metrics` and `hourly`.
The second example shows how to apply multiple tags to a saved query in the `semantic_model.yml` file. The saved query is then tagged with `order_metrics` and `hourly`.

<File name='semantic_model.yml'>

```yaml
saved_queries:
- name: order_metrics
...
exports:
- name: hourly_order_metrics
config:
alias: my_export_alias
export_as: table
schema: my_export_schema_name
tags:
- order_metrics
- hourly
- name: test_saved_query
description: "{{ doc('saved_query_description') }}"
label: Test saved query
config:
tags:
- order_metrics
- hourly
```

</File>
Expand Down

0 comments on commit e2ccfb3

Please sign in to comment.