Initial publish of dbt_f2dq (f2dq) package v0.12.1.
Clean package repo for Gitea installs via packages.yml git URL. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
{# Dual-read helpers for migrating from re_data → f2dq without breaking
|
||||
projects that still use re_data_* config keys or re_data:* vars. #}
|
||||
|
||||
{% macro f2dq_var(name, default=none) %}
|
||||
{# Prefer f2dq:<name>; fall back to re_data:<name>; then default.
|
||||
For booleans, either namespace set to true wins (so a project that
|
||||
still sets re_data:store_table_samples: true keeps working even
|
||||
though the package default for f2dq:store_table_samples is false). #}
|
||||
{% set fkey = 'f2dq:' ~ name %}
|
||||
{% set rkey = 're_data:' ~ name %}
|
||||
{% set fval = var(fkey) if var.has_var(fkey) else none %}
|
||||
{% set rval = var(rkey) if var.has_var(rkey) else none %}
|
||||
{% if fval is sameas true or rval is sameas true %}
|
||||
{{ return(true) }}
|
||||
{% elif fval is sameas false and rval is sameas false %}
|
||||
{{ return(false) }}
|
||||
{% elif fval is not none and fval is not sameas false %}
|
||||
{{ return(fval) }}
|
||||
{% elif rval is not none and rval is not sameas false %}
|
||||
{{ return(rval) }}
|
||||
{% elif fval is not none %}
|
||||
{{ return(fval) }}
|
||||
{% elif rval is not none %}
|
||||
{{ return(rval) }}
|
||||
{% else %}
|
||||
{{ return(default) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro f2dq_node_config(el, key, default=none) %}
|
||||
{# Read f2dq_<key> / re_data_<key> from node config, then config.meta /
|
||||
node.meta (dbt 1.12 CustomKeyInConfigDeprecation migration path).
|
||||
`key` is the suffix without package prefix, e.g. 'monitored',
|
||||
'time_filter', 'metrics_groups'. #}
|
||||
{% set keys = ['f2dq_' ~ key, 're_data_' ~ key] %}
|
||||
{% for k in keys %}
|
||||
{% if el.config is mapping and el.config.get(k) is not none %}
|
||||
{{ return(el.config.get(k)) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% set conf_meta = el.config.get('meta', {}) if el.config is mapping else {} %}
|
||||
{% if conf_meta is mapping %}
|
||||
{% for k in keys %}
|
||||
{% if conf_meta.get(k) is not none %}
|
||||
{{ return(conf_meta.get(k)) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% set node_meta = el.get('meta', {}) if el is mapping else {} %}
|
||||
{% if node_meta is mapping %}
|
||||
{% for k in keys %}
|
||||
{% if node_meta.get(k) is not none %}
|
||||
{{ return(node_meta.get(k)) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{{ return(default) }}
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user