Hi,
I’m having issues with {{ this }}
variable being properly resolved when used in the config block. I’m using incremental_predicates
config to add filtering expression into a MERGE statement in which I want to use max column value from target table, which is {{ this }}
. However, in the context of config {{ this }}
is being incorrectly resolved, it does not add a “schema suffix” that I declared in dbt_project.yml
So basically {{ this }}
is being resolved in two ways:
- In the model itself -
database.dbt_myuser_custom_suffix.table
- In the config context -
database.dbt_myuser.table
Below is the macro I’m using to insert an expression into incremental_predicates
param in the config:
{% macro get_incremental_predicates_expr(target_update_col, late_data_interval) -%}
{% if overwrite_partition_start_date -%}
TRUE
{% else -%}
DBT_INTERNAL_DEST.{{target_update_col}} >= DATE_TRUNC('DAY', (SELECT MAX({{ target_update_col }}) FROM {{ this }})::DATE) - INTERVAL '{{late_data_interval}}'
{% endif -%}
{% endmacro -%}
This makes MERGE statement to fail because it cannot find specified table. Any ideas how to resolve this?