From 3f7349ecbd053da3e062ffcca8471c3e7a4ff4c9 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Wed, 2 Oct 2024 16:16:15 +0100 Subject: [PATCH 01/20] Created snippet file --- website/snippets/_about_dbt_build_command.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 website/snippets/_about_dbt_build_command.md diff --git a/website/snippets/_about_dbt_build_command.md b/website/snippets/_about_dbt_build_command.md new file mode 100644 index 00000000000..e69de29bb2d From f01188f30c29e5ebd93ac327448e715035a7e8ae Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Wed, 2 Oct 2024 16:24:31 +0100 Subject: [PATCH 02/20] created snippet --- .../resource-configs/pre-hook-post-hook.md | 2 ++ website/snippets/_about_dbt_build_command.md | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/website/docs/reference/resource-configs/pre-hook-post-hook.md b/website/docs/reference/resource-configs/pre-hook-post-hook.md index e1e7d67f02e..e8864fba030 100644 --- a/website/docs/reference/resource-configs/pre-hook-post-hook.md +++ b/website/docs/reference/resource-configs/pre-hook-post-hook.md @@ -192,6 +192,8 @@ See: [Apache Spark docs on `ANALYZE TABLE`](https://spark.apache.org/docs/latest +import SQLcompilationerror from '/snippets/_About-dbt-build-command.md'; + ### Additional examples We've compiled some more in-depth examples [here](/docs/build/hooks-operations#additional-examples). diff --git a/website/snippets/_about_dbt_build_command.md b/website/snippets/_about_dbt_build_command.md index e69de29bb2d..3a1e8ff856e 100644 --- a/website/snippets/_about_dbt_build_command.md +++ b/website/snippets/_about_dbt_build_command.md @@ -0,0 +1,25 @@ +#### SQL compilation error when running the `--empty` flag on a model + +If you encounter the error: `SQL compilation error: syntax error line 1 at position 21 unexpected '('.` when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. + + + + +```Jinja + +-- models/staging/stg_sys__customers.sql +{{ config( + pre_hook = [ + "alter external table {{ source('sys', 'customers').render() }} refresh" + ] +) }} + +with cus as ( + select * from {{ source("sys", "customers") }} -- leave this as is! +) + +select * from cus + +``` + + \ No newline at end of file From dd354e0612a24d5024d2b718042156eb5534b2f3 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Thu, 3 Oct 2024 12:34:34 +0100 Subject: [PATCH 03/20] Updated snippets file, reworded build file, and added reusable snipper --- website/docs/reference/commands/build.md | 27 ++----------------- .../resource-configs/pre-hook-post-hook.md | 4 ++- website/snippets/_about_dbt_build_command.md | 25 ----------------- website/snippets/_render-method.md | 27 +++++++++++++++++++ 4 files changed, 32 insertions(+), 51 deletions(-) delete mode 100644 website/snippets/_about_dbt_build_command.md create mode 100644 website/snippets/_render-method.md diff --git a/website/docs/reference/commands/build.md b/website/docs/reference/commands/build.md index c7ac29862c2..9f8e83d2abd 100644 --- a/website/docs/reference/commands/build.md +++ b/website/docs/reference/commands/build.md @@ -31,32 +31,9 @@ In DAG order, for selected resources or an entire project. The `build` command supports the `--empty` flag for building schema-only dry runs. The `--empty` flag limits the refs and sources to zero rows. dbt will still execute the model SQL against the target data warehouse but will avoid expensive reads of input data. This validates dependencies and ensures your models will build properly. -#### SQL compilation error when running the `--empty` flag on a model - -If you encounter the error: `SQL compilation error: syntax error line 1 at position 21 unexpected '('.` when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. - - - - -```Jinja - --- models/staging/stg_sys__customers.sql -{{ config( - pre_hook = [ - "alter external table {{ source('sys', 'customers').render() }} refresh" - ] -) }} - -with cus as ( - select * from {{ source("sys", "customers") }} -- leave this as is! -) - -select * from cus - -``` - - +import SQLCompilationError from '/snippets/_render-method.md'; + ## Tests diff --git a/website/docs/reference/resource-configs/pre-hook-post-hook.md b/website/docs/reference/resource-configs/pre-hook-post-hook.md index e8864fba030..e31bd79d80a 100644 --- a/website/docs/reference/resource-configs/pre-hook-post-hook.md +++ b/website/docs/reference/resource-configs/pre-hook-post-hook.md @@ -192,7 +192,9 @@ See: [Apache Spark docs on `ANALYZE TABLE`](https://spark.apache.org/docs/latest -import SQLcompilationerror from '/snippets/_About-dbt-build-command.md'; +import SQLCompilationError from '/snippets/_render-method.md'; + + ### Additional examples We've compiled some more in-depth examples [here](/docs/build/hooks-operations#additional-examples). diff --git a/website/snippets/_about_dbt_build_command.md b/website/snippets/_about_dbt_build_command.md deleted file mode 100644 index 3a1e8ff856e..00000000000 --- a/website/snippets/_about_dbt_build_command.md +++ /dev/null @@ -1,25 +0,0 @@ -#### SQL compilation error when running the `--empty` flag on a model - -If you encounter the error: `SQL compilation error: syntax error line 1 at position 21 unexpected '('.` when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. - - - - -```Jinja - --- models/staging/stg_sys__customers.sql -{{ config( - pre_hook = [ - "alter external table {{ source('sys', 'customers').render() }} refresh" - ] -) }} - -with cus as ( - select * from {{ source("sys", "customers") }} -- leave this as is! -) - -select * from cus - -``` - - \ No newline at end of file diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md new file mode 100644 index 00000000000..7bad9e0de8a --- /dev/null +++ b/website/snippets/_render-method.md @@ -0,0 +1,27 @@ +#### SQL compilation error when running the `--empty` flag on a model + +If you encounter a SQL compilation error when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. The error occurs because dbt processes certain parts of the workflow differently when the `--empty flag` is used, leading to confusion when it encounters the table reference (`{{ source(...) }}`) in the pre-hook. The error you're seeing is a result of dbt not handling the reference as you anticipated. + +The recommended solution is to explicitly instruct dbt on how to interpret the reference in the pre-hook by using the `.render()` method. This approach ensures that dbt properly prepares the reference before executing it. + + + + +```Jinja + +-- models/staging/stg_sys__customers.sql +{{ config( + pre_hook = [ + "alter external table {{ source('sys', 'customers').render() }} refresh" + ] +) }} + +with cus as ( + select * from {{ source("sys", "customers") }} -- leave this as is! +) + +select * from cus + +``` + + \ No newline at end of file From c3e578d9037fd5039009caf6f25185eaf6c1c383 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:40:31 +0100 Subject: [PATCH 04/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 7bad9e0de8a..f74e3a7ee5f 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -1,4 +1,4 @@ -#### SQL compilation error when running the `--empty` flag on a model +#### The render method If you encounter a SQL compilation error when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. The error occurs because dbt processes certain parts of the workflow differently when the `--empty flag` is used, leading to confusion when it encounters the table reference (`{{ source(...) }}`) in the pre-hook. The error you're seeing is a result of dbt not handling the reference as you anticipated. From 222d8aa65fdfab9ac3395686d736253d08605514 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:50:25 +0100 Subject: [PATCH 05/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index f74e3a7ee5f..dbe0a69f90f 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -1,6 +1,6 @@ #### The render method -If you encounter a SQL compilation error when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. The error occurs because dbt processes certain parts of the workflow differently when the `--empty flag` is used, leading to confusion when it encounters the table reference (`{{ source(...) }}`) in the pre-hook. The error you're seeing is a result of dbt not handling the reference as you anticipated. +The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as --empty) are applied. The recommended solution is to explicitly instruct dbt on how to interpret the reference in the pre-hook by using the `.render()` method. This approach ensures that dbt properly prepares the reference before executing it. From 290defac2a0ec5f5c4a7c0d5e4c5ccb40ff9d15d Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:51:09 +0100 Subject: [PATCH 06/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index dbe0a69f90f..266fae22755 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -1,6 +1,6 @@ #### The render method -The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as --empty) are applied. +The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as `--empty`) are applied. The recommended solution is to explicitly instruct dbt on how to interpret the reference in the pre-hook by using the `.render()` method. This approach ensures that dbt properly prepares the reference before executing it. From b7f20a04193a31ce2eb4150afbfe5da34833a93c Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:55:21 +0100 Subject: [PATCH 07/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 266fae22755..547c1b9764d 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -2,7 +2,7 @@ The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as `--empty`) are applied. -The recommended solution is to explicitly instruct dbt on how to interpret the reference in the pre-hook by using the `.render()` method. This approach ensures that dbt properly prepares the reference before executing it. +When using the --empty flag, dbt may skip processing `ref()` or `source()` for optimization. To avoid compilation errors and to explicitly tell dbt to process a specific relation (`ref()` or `source()`), use the `.render()` method in your model file. From 98cc86cfab8403fe927438d0a679ff360e5e67c8 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:56:56 +0100 Subject: [PATCH 08/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 547c1b9764d..85a182fbf50 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -2,7 +2,7 @@ The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as `--empty`) are applied. -When using the --empty flag, dbt may skip processing `ref()` or `source()` for optimization. To avoid compilation errors and to explicitly tell dbt to process a specific relation (`ref()` or `source()`), use the `.render()` method in your model file. +When using the --empty flag, dbt may skip processing `ref()` or `source()` for optimization. To avoid compilation errors and to explicitly tell dbt to process a specific relation (`ref()` or `source()`), use the `.render()` method in your model file. For example: From 7dbe42ab562826f421a58d367bb296864d96d820 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:59:02 +0100 Subject: [PATCH 09/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 85a182fbf50..acbcb187dcb 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -24,4 +24,6 @@ select * from cus ``` - \ No newline at end of file + + +From there, run dbt run `--select stg_jaffle__customers --empty` \ No newline at end of file From 7492b0e75103e77fe782837115bbd01e3ae40dde Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:59:38 +0100 Subject: [PATCH 10/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index acbcb187dcb..1a01b966990 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -26,4 +26,4 @@ select * from cus -From there, run dbt run `--select stg_jaffle__customers --empty` \ No newline at end of file +From there, run `dbt run --select stg_jaffle__customers --empty` \ No newline at end of file From 37b9c02dc14621c767b09fc9be138812583bacb0 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Thu, 3 Oct 2024 14:12:31 +0100 Subject: [PATCH 11/20] Updated render method --- .../resource-configs/pre-hook-post-hook.md | 8 ++++---- website/snippets/_render-method.md | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/website/docs/reference/resource-configs/pre-hook-post-hook.md b/website/docs/reference/resource-configs/pre-hook-post-hook.md index e31bd79d80a..6cf42b563cc 100644 --- a/website/docs/reference/resource-configs/pre-hook-post-hook.md +++ b/website/docs/reference/resource-configs/pre-hook-post-hook.md @@ -151,6 +151,10 @@ Pre- and post-hooks can also call macros that return SQL statements. If your mac dbt aims to provide all the boilerplate SQL you need (DDL, DML, and DCL) via out-of-the-box functionality, which you can configure quickly and concisely. In some cases, there may be SQL that you want or need to run, specific to functionality in your data platform, which dbt does not (yet) offer as a built-in feature. In those cases, you can write the exact SQL you need, using dbt's compilation context, and pass it into a `pre-` or `post-` hook to run before or after your model, seed, or snapshot. +import SQLCompilationError from '/snippets/_render-method.md'; + + + ## Examples @@ -192,10 +196,6 @@ See: [Apache Spark docs on `ANALYZE TABLE`](https://spark.apache.org/docs/latest -import SQLCompilationError from '/snippets/_render-method.md'; - - - ### Additional examples We've compiled some more in-depth examples [here](/docs/build/hooks-operations#additional-examples). diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 7bad9e0de8a..a7609000683 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -1,27 +1,25 @@ -#### SQL compilation error when running the `--empty` flag on a model +#### The render method -If you encounter a SQL compilation error when running a model with the `--empty` flag, explicitly call the `.render()` method on that relation. The error occurs because dbt processes certain parts of the workflow differently when the `--empty flag` is used, leading to confusion when it encounters the table reference (`{{ source(...) }}`) in the pre-hook. The error you're seeing is a result of dbt not handling the reference as you anticipated. +The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as `--empty`) are applied. -The recommended solution is to explicitly instruct dbt on how to interpret the reference in the pre-hook by using the `.render()` method. This approach ensures that dbt properly prepares the reference before executing it. +When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for optimization. To avoid compilation errors and to explicitly tell dbt to process a specific relation (`ref()` or `source()`), use the `.render()` method in your model file. For example: ```Jinja - -- models/staging/stg_sys__customers.sql {{ config( pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] ) }} - with cus as ( select * from {{ source("sys", "customers") }} -- leave this as is! ) - select * from cus - ``` - \ No newline at end of file + + +From there, run `dbt run --select stg_jaffle__customers --empty` \ No newline at end of file From cb0e4b937f218dd9ff0d4609bd2985a099b84d21 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:16:49 +0100 Subject: [PATCH 12/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index a7609000683..be653b5d60a 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -8,7 +8,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for ```Jinja --- models/staging/stg_sys__customers.sql {{ config( pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" From c1d859cb4e4a98454773ccb3c5ffa46b2caa4ede Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:18:21 +0100 Subject: [PATCH 13/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index be653b5d60a..1b848096776 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -20,5 +20,3 @@ select * from cus ``` - -From there, run `dbt run --select stg_jaffle__customers --empty` \ No newline at end of file From 6b26b373cb663b54b3f21dce420204db5ba1360c Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:19:23 +0100 Subject: [PATCH 14/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 1b848096776..42369561dd2 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -12,7 +12,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] -) }} with cus as ( select * from {{ source("sys", "customers") }} -- leave this as is! ) From 9d746cad28b2e06a8fe91b94299f50ba85c60161 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:19:40 +0100 Subject: [PATCH 15/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 42369561dd2..680e33f6868 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -12,7 +12,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] -with cus as ( select * from {{ source("sys", "customers") }} -- leave this as is! ) select * from cus From e1a218a6761f7d185de69ca01ff987b9cfb7b36e Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:20:07 +0100 Subject: [PATCH 16/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 680e33f6868..d8a06cb1a66 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -12,7 +12,7 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] - select * from {{ source("sys", "customers") }} -- leave this as is! + select * from {{ source("sys", "customers") }} ) select * from cus ``` From b6f6a1b838855cf6f2cb3373278085009e0f3040 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:20:24 +0100 Subject: [PATCH 17/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index d8a06cb1a66..3463fd5ec65 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -13,7 +13,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for "alter external table {{ source('sys', 'customers').render() }} refresh" ] select * from {{ source("sys", "customers") }} -) select * from cus ``` From 15dd0f23a454eaaab84ab145aad92603598926cf Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:20:41 +0100 Subject: [PATCH 18/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index 3463fd5ec65..df5463cd9f7 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -12,7 +12,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] - select * from {{ source("sys", "customers") }} select * from cus ``` From 676f4c7720381979ce837ccc8c1b0b54d77e250e Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:21:05 +0100 Subject: [PATCH 19/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index df5463cd9f7..f81960c3c93 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -12,7 +12,6 @@ When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for pre_hook = [ "alter external table {{ source('sys', 'customers').render() }} refresh" ] -select * from cus ``` From 2fa5ba4b32265c5b2ce9d0d80318ae3a56845546 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:44:51 +0100 Subject: [PATCH 20/20] Update website/snippets/_render-method.md --- website/snippets/_render-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/snippets/_render-method.md b/website/snippets/_render-method.md index f81960c3c93..00407a20251 100644 --- a/website/snippets/_render-method.md +++ b/website/snippets/_render-method.md @@ -1,6 +1,6 @@ #### The render method -The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When a pre-hook or post-hook contains a dynamic reference, such as a table or column, dbt might not automatically resolve the reference correctly, particularly when certain flags (such as `--empty`) are applied. +The `.render()` method is generally used to resolve or evaluate Jinja expressions (such as `{{ source(...) }}`) during runtime. When using the `--empty flag`, dbt may skip processing `ref()` or `source()` for optimization. To avoid compilation errors and to explicitly tell dbt to process a specific relation (`ref()` or `source()`), use the `.render()` method in your model file. For example: