From 184924b27017997249c03ed76d027bb513e9436d Mon Sep 17 00:00:00 2001 From: "Alison (she/her)" Date: Sat, 23 Sep 2023 15:14:56 -0400 Subject: [PATCH 1/4] Update usage methods, File formatting, and version numbers * Updated first version for Dispatch to 1.0. I'm using it in 1.4 so it had to be introduced before what was stated. The `dispatch` doc page says 1.0. I also updated the link to have the in-page reference it seemed to want. I re-titled the section header so it would stand out in the right navigation and be more descriptive. * I added the File macro around two files that were missing it. * I added an example of configuring an alias in YAML instead of Jinja. --- website/docs/docs/build/custom-aliases.md | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index 326434ea922..6832ff0de49 100644 --- a/website/docs/docs/build/custom-aliases.md +++ b/website/docs/docs/build/custom-aliases.md @@ -34,6 +34,19 @@ select * from ... +Or in a `schema.yml` file. + + + +```yaml +- models: + - name: ga_sessions + config: + alias: sessions +``` + + + When referencing the `ga_sessions` model above from a different model, use the `ref()` function with the model's _filename_ as usual. For example: @@ -114,11 +127,11 @@ The default implementation of `generate_alias_name` simply uses the supplied `al - + -### Managing different behaviors across packages +### Dispatch - Managing aliasing across SQL dialects, data platforms, and dbt packages -See docs on macro `dispatch`: ["Managing different global overrides across packages"](/reference/dbt-jinja-functions/dispatch) +See docs on macro `dispatch`: ["Managing different global overrides across packages"](/reference/dbt-jinja-functions/dispatch#managing-different-global-overrides-across-packages) @@ -128,20 +141,23 @@ See docs on macro `dispatch`: ["Managing different global overrides across packa Using aliases, it's possible to accidentally create models with ambiguous identifiers. Given the following two models, dbt would attempt to create two views with _exactly_ the same names in the database (ie. `sessions`): -```sql --- models/snowplow_sessions.sql + +```sql {{ config(alias='sessions') }} select * from ... ``` + -```sql --- models/sessions.sql + +```sql select * from ... ``` + + Whichever one of these models runs second would "win", and generally, the output of dbt would not be what you would expect. To avoid this failure mode, dbt will check if your model names and aliases are ambiguous in nature. If they are, you will be presented with an error message like this: ``` From 7150cd20ebabdbb6661bd9a4424611006008e82a Mon Sep 17 00:00:00 2001 From: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:40:49 +0000 Subject: [PATCH 2/4] Update custom-aliases.md removing version block as 1.0 is deprecated and this applies to existing version (1.2 and higher) --- website/docs/docs/build/custom-aliases.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index 6832ff0de49..063ba7dda49 100644 --- a/website/docs/docs/build/custom-aliases.md +++ b/website/docs/docs/build/custom-aliases.md @@ -127,13 +127,11 @@ The default implementation of `generate_alias_name` simply uses the supplied `al - ### Dispatch - Managing aliasing across SQL dialects, data platforms, and dbt packages See docs on macro `dispatch`: ["Managing different global overrides across packages"](/reference/dbt-jinja-functions/dispatch#managing-different-global-overrides-across-packages) - ### Caveats From 47f355440fd46240b8537114c6eddf37f3e64b1f Mon Sep 17 00:00:00 2001 From: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:44:12 +0000 Subject: [PATCH 3/4] Update website/docs/docs/build/custom-aliases.md --- website/docs/docs/build/custom-aliases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index 063ba7dda49..dd95619207c 100644 --- a/website/docs/docs/build/custom-aliases.md +++ b/website/docs/docs/build/custom-aliases.md @@ -128,7 +128,7 @@ The default implementation of `generate_alias_name` simply uses the supplied `al -### Dispatch - Managing aliasing across SQL dialects, data platforms, and dbt packages +### Dispatch macro - SQL alias management for databases and dbt packages See docs on macro `dispatch`: ["Managing different global overrides across packages"](/reference/dbt-jinja-functions/dispatch#managing-different-global-overrides-across-packages) From 0dc3933a2171d235a8e813f691b5c7b3bbee6fa4 Mon Sep 17 00:00:00 2001 From: mirnawong1 <89008547+mirnawong1@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:46:05 +0000 Subject: [PATCH 4/4] Update custom-aliases.md fix yaml indentation --- website/docs/docs/build/custom-aliases.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index dd95619207c..b4962aad00a 100644 --- a/website/docs/docs/build/custom-aliases.md +++ b/website/docs/docs/build/custom-aliases.md @@ -40,8 +40,8 @@ Or in a `schema.yml` file. ```yaml - models: - - name: ga_sessions - config: + - name: ga_sessions + config: alias: sessions ```