From 81992fd35323871be2339b621e78aed42ce6dc8a Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:09:09 +0000 Subject: [PATCH 1/5] add supported examples for alias this pr adds additional examples for the `alias` config for the supported resources. missing examples were for dbt_projct.yml, properties.yml, and sql config block (depending on the resource) Resolves #6512 --- .../docs/reference/resource-configs/alias.md | 112 ++++++++++++++++-- 1 file changed, 102 insertions(+), 10 deletions(-) diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md index c14804ef2a7..33e577ec5a4 100644 --- a/website/docs/reference/resource-configs/alias.md +++ b/website/docs/reference/resource-configs/alias.md @@ -8,9 +8,11 @@ datatype: string -Specify a custom alias for a model in your `dbt_project.yml` file or config block. +Specify a custom alias for a model in your `dbt_project.yml` file, `models/properties.yml` file, or config block in a SQL file. -For example, if you have a model that calculates `sales_total` and want to give it a more user-friendly alias, you can alias it like this: +For example, if you have a model that calculates `sales_total` and want to give it a more user-friendly alias, you can alias it as shown in the following examples. + +In the `dbt_project.yml` file, the following example sets a default `alias` for the `sales_total` model at the project level: @@ -22,16 +24,40 @@ models: ``` +In the `models/properties.yml` file, the following specifies an `alias` as part of the model's metadata, useful for centralized configuration: + + + +```yml +version: 2 + +models: + - name: sales_total + config: + alias: sales_dashboard +``` + + +In `models/sales_total.sql` file, the following assigns the `alias` directly in the model file: + + + +```sql +{{ config( + alias="sales_dashboard" +) }} +``` + + This would return `analytics.finance.sales_dashboard` in the database, instead of the default `analytics.finance.sales_total`. +Configure a seed's alias in your `dbt_project.yml` file or a `properties.yml` file. The following examples demonstrate how to `alias` a seed named `product_categories` to `categories_data`. -Configure a seed's alias in your `dbt_project.yml` file or config block. - -For example, if you have a seed that represents `product_categories` and want to alias it as `categories_data`, you would alias like this: +In the `dbt_project.yml` file at the project level: @@ -41,6 +67,21 @@ seeds: product_categories: +alias: categories_data ``` + + +In the `seeds/properties.yml` file: + + + +```yml +version: 2 + +seeds: + - name: product_categories + config: + alias: categories_data +``` + This would return the name `analytics.finance.categories_data` in the database. @@ -65,7 +106,9 @@ seeds: Configure a snapshots's alias in your `dbt_project.yml` file or config block. -For example, if you have a snapshot that is named `your_snapshot` and want to alias it as `the_best_snapshot`, you would alias like this: +The following examples demonstrate how to `alias` a snapshot named `your_snapshot` to `the_best_snapshot`. + +In the `dbt_project.yml` file at the project level: @@ -75,20 +118,57 @@ snapshots: your_snapshot: +alias: the_best_snapshot ``` + -This would build your snapshot to `analytics.finance.the_best_snapshot` in the database. +In the `snapshots/properties.yml` file: + + +```yml +version: 2 + +snapshots: + - name: your_snapshot + config: + alias: the_best_snapshot +``` + + +In `snapshots/your_snapshot.sql` file: + + + +```sql +{{ config( + alias="the_best_snapshot" +) }} +``` +This would build your snapshot to `analytics.finance.the_best_snapshot` in the database. + -Configure a test's alias in your `schema.yml` file or config block. +Configure a data test's alias in your `dbt_project.yml` file, `properties.yml` file, or config block in the model file. + +The following examples demonstrate how to `alias` a unique data test named `order_id` to `unique_order_id_test` to identify a specific data test. -For example, to add a unique test to the `order_id` column and give it an alias `unique_order_id_test` to identify this specific test, you would alias like this: +In the `dbt_project.yml` file at the project level: - + + +```yml +tests: + your_project: + +alias: unique_order_id_test +``` + + +In the `models/properties.yml` file: + + ```yml models: @@ -99,6 +179,18 @@ models: - unique: alias: unique_order_id_test ``` + + +In `tests/unique_order_id_test.sql` file: + + + +```sql +{{ config( + alias="unique_order_id_test", + severity="error", +``` + When using [`store_failures_as`](/reference/resource-configs/store_failures_as), this would return the name `analytics.finance.orders_order_id_unique_order_id_test` in the database. From 8df1848f2c31fbffb618a80f2cbf3a82dbb10761 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:21:24 +0000 Subject: [PATCH 2/5] Update alias.md --- website/docs/reference/resource-configs/alias.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md index 33e577ec5a4..66e9e3f1074 100644 --- a/website/docs/reference/resource-configs/alias.md +++ b/website/docs/reference/resource-configs/alias.md @@ -96,9 +96,6 @@ seeds: +alias: country_mappings ``` - - - From ff4a383b0ff4008b170f9fc6b1dd8b4be1382565 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:48:28 +0000 Subject: [PATCH 3/5] Update alias.md --- website/docs/reference/resource-configs/alias.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md index 66e9e3f1074..b568c437fa9 100644 --- a/website/docs/reference/resource-configs/alias.md +++ b/website/docs/reference/resource-configs/alias.md @@ -191,7 +191,7 @@ In `tests/unique_order_id_test.sql` file: When using [`store_failures_as`](/reference/resource-configs/store_failures_as), this would return the name `analytics.finance.orders_order_id_unique_order_id_test` in the database. - + From 56e47da64aaeebc1ffcde068d41cbb7b8c2d16f7 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:11:22 +0000 Subject: [PATCH 4/5] Update website/docs/reference/resource-configs/alias.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/reference/resource-configs/alias.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md index b568c437fa9..dbb772ccee4 100644 --- a/website/docs/reference/resource-configs/alias.md +++ b/website/docs/reference/resource-configs/alias.md @@ -24,7 +24,7 @@ models: ``` -In the `models/properties.yml` file, the following specifies an `alias` as part of the model's metadata, useful for centralized configuration: +The following specifies an `alias` as part of the `models/properties.yml` file metadata, useful for centralized configuration: From 7af79c48688538f0cf31d0bfd06fbf121d9b8f4a Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:11:38 +0000 Subject: [PATCH 5/5] Update website/docs/reference/resource-configs/alias.md Co-authored-by: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> --- website/docs/reference/resource-configs/alias.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/resource-configs/alias.md b/website/docs/reference/resource-configs/alias.md index dbb772ccee4..5beaa238806 100644 --- a/website/docs/reference/resource-configs/alias.md +++ b/website/docs/reference/resource-configs/alias.md @@ -38,7 +38,7 @@ models: ``` -In `models/sales_total.sql` file, the following assigns the `alias` directly in the model file: +The following assigns the `alias` directly in the In `models/sales_total.sql` file: