diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index 326434ea922..b4962aad00a 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,13 +127,11 @@ The default implementation of `generate_alias_name` simply uses the supplied `al - -### Managing different behaviors across 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) +See docs on macro `dispatch`: ["Managing different global overrides across packages"](/reference/dbt-jinja-functions/dispatch#managing-different-global-overrides-across-packages) - ### Caveats @@ -128,20 +139,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: ```