我正在尝试根据基础源的“synced_at”列的中位数和标准差动态确定在 dbt sources.yml 中指定的新鲜度检查的警告和错误。
为此,我想我可能会尝试在 source.yml 文件的新鲜度块中传递一个宏,如下所示:
# sources.yml
...
tables:
- name: appointment_type
freshness:
error_after:
count: test_macro()
period: hour
...
在哪里:
{%- macro test_macro(this) -%}
{# /*
The idea is {{ this.table }} would parameterize a query,
going over the same column name for all sources, _fivetran_synced,
and spit out the calculated values I want. This makes me feel like
it needs to be a prehook, that somehow stores the value in a var,
and that is accessed in the source.yml, instead of calling it directly.
In this case a trivial integer is attempted to be returned, just as an example.
*/ #}
{{ return(24) }}
{%- endmacro -%}
但是,这会导致类型错误。大概宏根本没有被调用。用 jinja 引号括起来也会返回错误。
我很好奇目前是否可以通过任何方式将动态值传递给新鲜度检查?