This commit is contained in:
Grzegorz Michalski
2026-03-02 09:47:35 +01:00
commit 2c225d68ac
715 changed files with 130067 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
{% macro check_model_exists(model_name) %}
{% if execute %}
{% if manifest %}
{% set model_exists = false %}
{% for node in manifest.nodes.values() %}
{% if node.resource_type == 'model' and node.name == model_name %}
{% set model_exists = true %}
{% break %}
{% endif %}
{% endfor %}
{{ return(model_exists) }}
{% else %}
{{ exceptions.raise_compiler_error("'manifest' object is not available in this context.") }}
{% endif %}
{% endif %}
{% endmacro %}

View File

@@ -0,0 +1,15 @@
{% macro get_child_models(model_name) %}
{% if execute %}
{% set graph = graph.nodes %}
{% set children = [] %}
{% for node, details in graph.items() %}
{% for item in details.depends_on.nodes %}
{% if model_name == item.split('.')[2] %}
{% do children.append(node.split('.')[2]) %}
{% break %}
{% endif %}
{% endfor %}
{% endfor %}
{{ return(children) }}
{% endif %}
{% endmacro %}

View File

@@ -0,0 +1,12 @@
{% macro get_parent_models(model_name) %}
{% if execute %}
{% set model = ( graph.nodes.values() | selectattr('name', 'equalto', model_name) | list ).pop() %}
{% set depends_on = model.depends_on['nodes'] %}
{% set new_depends_on = [] %}
{% for item in depends_on %}
{% do new_depends_on.append(item.split('.')[2]) %}
{% endfor %}
{{ return(new_depends_on) }}
{% endif %}
{% endmacro %}

View File

@@ -0,0 +1,12 @@
{% macro get_table_qualified_name(model_name) %}
{% if execute %}
{% set models = graph.nodes.values() %}
{% set model = (models | selectattr('name', 'equalto', model_name) | list).pop() %}
{% if model is not none %}
{% set table_qualified_name = model.schema ~ '.' ~ model.alias if model.alias is not none and model.alias != '' else model.schema ~ '.' ~ model.name %}
{{ return(table_qualified_name) }}
{% else %}
{{ exceptions.raise("Model not found: " ~ model_name) }}
{% endif %}
{% endif %}
{% endmacro %}