From 27b513e6e85ecf4f47b7901dba46038ee4760bf6 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Thu, 15 Feb 2024 17:29:48 +0000 Subject: [PATCH 1/4] addd expandables --- website/docs/docs/build/custom-aliases.md | 3 +++ website/docs/docs/build/custom-databases.md | 4 ++++ website/docs/docs/build/custom-schemas.md | 9 ++++++--- website/docs/docs/build/jinja-macros.md | 3 +++ website/snippets/_whitespace-control.md | 7 +++++++ 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 website/snippets/_whitespace-control.md diff --git a/website/docs/docs/build/custom-aliases.md b/website/docs/docs/build/custom-aliases.md index b4962aad00a..2837e6d511a 100644 --- a/website/docs/docs/build/custom-aliases.md +++ b/website/docs/docs/build/custom-aliases.md @@ -127,6 +127,9 @@ The default implementation of `generate_alias_name` simply uses the supplied `al +import WhitespaceControl from '/snippets/_whitespace-control.md'; + + ### Dispatch macro - SQL alias management for databases and dbt packages diff --git a/website/docs/docs/build/custom-databases.md b/website/docs/docs/build/custom-databases.md index dd54d6998e8..3ffd8ae3354 100644 --- a/website/docs/docs/build/custom-databases.md +++ b/website/docs/docs/build/custom-databases.md @@ -85,6 +85,10 @@ The default implementation of `generate_database_name` simply uses the supplied +import WhitespaceControl from '/snippets/_whitespace-control.md'; + + + ### Managing different behaviors across packages diff --git a/website/docs/docs/build/custom-schemas.md b/website/docs/docs/build/custom-schemas.md index 24cd4194a1c..02324fadb0b 100644 --- a/website/docs/docs/build/custom-schemas.md +++ b/website/docs/docs/build/custom-schemas.md @@ -84,6 +84,10 @@ The following code represents the default macro's logic: {%- endmacro %} ``` +import WhitespaceControl from '/snippets/_whitespace-control.md'; + + + ## Changing the way dbt generates a schema name If your dbt project has a custom macro called `generate_schema_name`, dbt will use it instead of the default macro. This allows you to customize the name generation according to your needs. @@ -92,8 +96,7 @@ To customize this macro, copy the example code in the section [How does dbt gene Be careful. dbt will ignore any custom `generate_schema_name` macros included in installed packages. -
-❗️ Warning: Don't replace default_schema in the macro. + If you're modifying how dbt generates schema names, don't just replace ```{{ default_schema }}_{{ custom_schema_name | trim }}``` with ```{{ custom_schema_name | trim }}``` in the ```generate_schema_name``` macro. @@ -119,7 +122,7 @@ If you remove ```{{ default_schema }}```, it causes developers to override each ``` -
+ ### generate_schema_name arguments diff --git a/website/docs/docs/build/jinja-macros.md b/website/docs/docs/build/jinja-macros.md index ea60c7d48e0..cb839aa089c 100644 --- a/website/docs/docs/build/jinja-macros.md +++ b/website/docs/docs/build/jinja-macros.md @@ -124,6 +124,9 @@ from app_data.payments +import WhitespaceControl from '/snippets/_whitespace-control.md'; + + ### Using a macro from a package A number of useful macros have also been grouped together into [packages](/docs/build/packages) — our most popular package is [dbt-utils](https://hub.getdbt.com/dbt-labs/dbt_utils/latest/). diff --git a/website/snippets/_whitespace-control.md b/website/snippets/_whitespace-control.md new file mode 100644 index 00000000000..9b696447aa7 --- /dev/null +++ b/website/snippets/_whitespace-control.md @@ -0,0 +1,7 @@ + + + +When you're changing macros, like the `generate_schema_name` macro, in your project — you might notice extra white space in your code in the `target/compiled` folder. + +You can use Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) using a minus sign `(-)` to tidy that up and remove unwanted spaces/lines. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions( such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). + From e7dad3eb8463debb28472ec90904e5fa907a8e6e Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Thu, 15 Feb 2024 17:31:34 +0000 Subject: [PATCH 2/4] update --- website/snippets/_whitespace-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/snippets/_whitespace-control.md b/website/snippets/_whitespace-control.md index 9b696447aa7..d9fc88a1645 100644 --- a/website/snippets/_whitespace-control.md +++ b/website/snippets/_whitespace-control.md @@ -1,7 +1,7 @@ -When you're changing macros, like the `generate_schema_name` macro, in your project — you might notice extra white space in your code in the `target/compiled` folder. +When you're changing macros, like the `generate_schema_name`, in your project — you might notice extra white space in your code in the `target/compiled` folder. -You can use Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) using a minus sign `(-)` to tidy that up and remove unwanted spaces/lines. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions( such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). +You can use Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) using a minus sign `(-)` to tidy that up and remove unwanted spaces/lines. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions (such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). From 024116196698813c67e382d561ac7f91294d6b0c Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:34:19 +0000 Subject: [PATCH 3/4] Update website/snippets/_whitespace-control.md Co-authored-by: Ly Nguyen <107218380+nghi-ly@users.noreply.github.com> --- website/snippets/_whitespace-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_whitespace-control.md b/website/snippets/_whitespace-control.md index d9fc88a1645..3c3e298dd92 100644 --- a/website/snippets/_whitespace-control.md +++ b/website/snippets/_whitespace-control.md @@ -3,5 +3,5 @@ When you're changing macros, like the `generate_schema_name`, in your project — you might notice extra white space in your code in the `target/compiled` folder. -You can use Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) using a minus sign `(-)` to tidy that up and remove unwanted spaces/lines. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions (such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). +You can remove unwanted spaces and lines with Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) by using a minus sign. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions (such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). From 5e7c7b141e9d8e636de5546f5306e48c4538b131 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Mon, 19 Feb 2024 10:57:32 +0000 Subject: [PATCH 4/4] tweaks --- website/docs/docs/build/custom-schemas.md | 4 +++- website/snippets/_whitespace-control.md | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/website/docs/docs/build/custom-schemas.md b/website/docs/docs/build/custom-schemas.md index 02324fadb0b..970d782668b 100644 --- a/website/docs/docs/build/custom-schemas.md +++ b/website/docs/docs/build/custom-schemas.md @@ -83,11 +83,13 @@ The following code represents the default macro's logic: {%- endmacro %} ``` +
import WhitespaceControl from '/snippets/_whitespace-control.md'; + ## Changing the way dbt generates a schema name If your dbt project has a custom macro called `generate_schema_name`, dbt will use it instead of the default macro. This allows you to customize the name generation according to your needs. @@ -96,7 +98,7 @@ To customize this macro, copy the example code in the section [How does dbt gene Be careful. dbt will ignore any custom `generate_schema_name` macros included in installed packages. - + If you're modifying how dbt generates schema names, don't just replace ```{{ default_schema }}_{{ custom_schema_name | trim }}``` with ```{{ custom_schema_name | trim }}``` in the ```generate_schema_name``` macro. diff --git a/website/snippets/_whitespace-control.md b/website/snippets/_whitespace-control.md index 3c3e298dd92..c2f275ba9dd 100644 --- a/website/snippets/_whitespace-control.md +++ b/website/snippets/_whitespace-control.md @@ -1,7 +1,8 @@ +
+💡 Use Jinja's whitespace control to tidy your macros! - - -When you're changing macros, like the `generate_schema_name`, in your project — you might notice extra white space in your code in the `target/compiled` folder. +When you're modifying macros in your project, you might notice extra white space in your code in the `target/compiled` folder. You can remove unwanted spaces and lines with Jinja's [whitespace control](/faqs/Jinja/jinja-whitespace) by using a minus sign. For example, use `{{- ... -}}` or `{%- ... %}` around your macro definitions (such as `{%- macro generate_schema_name(...) -%} ... {%- endmacro -%}`). - + +