added package name to internal macros

This commit is contained in:
Grace Goheen
2022-06-07 14:52:39 -04:00
parent 035a1e7e72
commit 18f66e7669
20 changed files with 56 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
{% macro array_append(array, new_element) -%}
{{ return(adapter.dispatch('array_append')(array, new_element)) }}
{{ return(adapter.dispatch('array_append', 'dbt_project_evaluator')(array, new_element)) }}
{%- endmacro %}
{# new_element must be the same data type as elements in array to match postgres functionality #}
@@ -8,9 +8,9 @@
{%- endmacro %}
{% macro bigquery__array_append(array, new_element) -%}
array_concat({{ array }}, {{ create_array([new_element]) }})
array_concat({{ array }}, {{ dbt_project_evaluator.create_array([new_element]) }})
{%- endmacro %}
{% macro redshift__array_append(array, new_element) -%}
array_concat({{ array }}, {{ create_array([new_element]) }})
array_concat({{ array }}, {{ dbt_project_evaluator.create_array([new_element]) }})
{%- endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro create_array(inputs=[]) -%}
{{ return(adapter.dispatch('array')(inputs)) }}
{{ return(adapter.dispatch('array', 'dbt_project_evaluator')(inputs)) }}
{%- endmacro %}
{# all inputs must be the same data type to match postgres functionality #}

View File

@@ -1,4 +1,8 @@
{% macro is_not_empty_string(str) %}
{{ return(adapter.dispatch('is_not_empty_string', 'dbt_project_evaluator')(str)) }}
{% endmacro %}
{% macro default__is_not_empty_string(str) %}
{% if str %}
{{ true }}

View File

@@ -1,4 +1,8 @@
{% macro loop_vars(vars) %}
{{ return(adapter.dispatch('loop_vars', 'dbt_project_evaluator')(vars)) }}
{% endmacro %}
{% macro default__loop_vars(vars) %}
{%- set sql_query = [] -%}
{%- for var_name in vars -%}
{%- if var(var_name,[]) is not string -%}

View File

@@ -54,7 +54,7 @@ all_relationships (
directory_path as child_directory_path,
file_name as child_file_name,
0 as distance,
{{ create_array(['resource_name']) }} as path
{{ dbt_project_evaluator.create_array(['resource_name']) }} as path
from direct_relationships
-- where direct_parent is null {# optional lever to change filtering of anchor clause to only include root resources #}
@@ -80,7 +80,7 @@ all_relationships (
direct_relationships.directory_path as child_directory_path,
direct_relationships.file_name as child_file_name,
all_relationships.distance+1 as distance,
{{ array_append('all_relationships.path', 'direct_relationships.resource_name') }} as path
{{ dbt_project_evaluator.array_append('all_relationships.path', 'direct_relationships.resource_name') }} as path
from direct_relationships
inner join all_relationships
@@ -119,7 +119,7 @@ with direct_relationships as (
parent_id,
child_id,
0 as distance,
{{ create_array(['resource_name']) }} as path
{{ dbt_project_evaluator.create_array(['resource_name']) }} as path
from get_distinct
)
@@ -130,7 +130,7 @@ with direct_relationships as (
cte_{{i - 1}}.parent_id as parent_id,
direct_relationships.resource_id as child_id,
cte_{{i - 1}}.distance+1 as distance,
{{ array_append(prev_cte_path, 'direct_relationships.resource_name') }} as path
{{ dbt_project_evaluator.array_append(prev_cte_path, 'direct_relationships.resource_name') }} as path
from direct_relationships
inner join cte_{{i - 1}}

View File

@@ -1,4 +1,8 @@
{% macro get_exposures() %}
{{ return(adapter.dispatch('get_exposures', 'dbt_project_evaluator')()) }}
{% endmacro %}
{% macro default__get_exposures() %}
{% if execute %}
{% set nodes_list = graph.exposures.values() %}
@@ -12,7 +16,7 @@
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.original_file_path }}',
cast('{{ is_not_empty_string(node.description) | trim }}'as boolean),
cast('{{ dbt_project_evaluator.is_not_empty_string(node.description) | trim }}'as boolean),
'{{ node.type }}',
'{{ node.maturity}}',
'{{ node.package_name }}',
@@ -25,7 +29,7 @@
{% endif %}
{{ return(
select_from_values(
dbt_project_evaluator.select_from_values(
values = values,
column_names = [
'unique_id',

View File

@@ -1,4 +1,8 @@
{% macro get_metrics() %}
{{ return(adapter.dispatch('get_metrics', 'dbt_project_evaluator')()) }}
{% endmacro %}
{% macro default__get_metrics() %}
{% if execute %}
{% set nodes_list = graph.metrics.values() %}
@@ -12,7 +16,7 @@
'{{ node.name }}',
'{{ node.resource_type }}',
'{{ node.original_file_path }}',
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ dbt_project_evaluator.is_not_empty_string(node.description) | trim }}' as boolean),
'{{ node.type }}',
'{{ node.model.identifier }}',
'{{ node.label }}',
@@ -27,7 +31,7 @@
{% endif %}
{{ return(
select_from_values(
dbt_project_evaluator.select_from_values(
values = values,
column_names = [
'unique_id',

View File

@@ -1,4 +1,8 @@
{% macro get_nodes() %}
{{ return(adapter.dispatch('get_nodes', 'dbt_project_evaluator')()) }}
{% endmacro %}
{% macro default__get_nodes() %}
{% if execute %}
{% set nodes_list = graph.nodes.values() %}
@@ -19,7 +23,7 @@
'{{ node.schema }}',
'{{ node.package_name }}',
'{{ node.alias }}',
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ dbt_project_evaluator.is_not_empty_string(node.description) | trim }}' as boolean),
'{{ "" if not node.column_name else node.column_name }}'
{% endset %}
@@ -29,7 +33,7 @@
{% endif %}
{{ return(
select_from_values(
dbt_project_evaluator.select_from_values(
values = values,
column_names = [
'unique_id',

View File

@@ -1,4 +1,8 @@
{% macro get_relationships(node_type) %}
{{ return(adapter.dispatch('get_relationships', 'dbt_project_evaluator')(node_type)) }}
{% endmacro %}
{% macro default__get_relationships(node_type) %}
{% if execute %}
@@ -39,7 +43,7 @@
{% endfor -%}
{{ return(
select_from_values(
dbt_project_evaluator.select_from_values(
values = values,
column_names = [
'resource_id',

View File

@@ -1,4 +1,8 @@
{% macro get_sources() %}
{{ return(adapter.dispatch('get_sources', 'dbt_project_evaluator')()) }}
{% endmacro %}
{% macro default__get_sources() %}
{% if execute %}
{% set nodes_list = graph.sources.values() %}
@@ -14,8 +18,8 @@
'{{ node.alias }}',
'{{ node.resource_type }}',
'{{ node.source_name }}',
cast('{{ is_not_empty_string(node.source_description) | trim }}' as boolean),
cast('{{ is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ dbt_project_evaluator.is_not_empty_string(node.source_description) | trim }}' as boolean),
cast('{{ dbt_project_evaluator.is_not_empty_string(node.description) | trim }}' as boolean),
cast('{{ node.config.enabled }}' as boolean),
'{{ node.loaded_at_field | replace("'", "_") }}}}',
'{{ node.database }}',
@@ -32,7 +36,7 @@
{{ return(
select_from_values(
dbt_project_evaluator.select_from_values(
values = values,
column_names = [
'unique_id',

View File

@@ -1,5 +1,5 @@
-- creates a cte called all_relationships that will either use "with recursive" or loops depending on the DW
{{ recursive_dag() }}
{{ dbt_project_evaluator.recursive_dag() }}
select * from all_relationships
order by parent, distance

View File

@@ -1,7 +1,7 @@
with relationships as (
{{
get_relationships("exposures")
dbt_project_evaluator.get_relationships("exposures")
}}
),

View File

@@ -1,4 +1,4 @@
{{
get_exposures()
dbt_project_evaluator.get_exposures()
}}

View File

@@ -1,7 +1,7 @@
with relationships as (
{{
get_relationships("metrics")
dbt_project_evaluator.get_relationships("metrics")
}}
),

View File

@@ -1,4 +1,4 @@
{{
get_metrics()
dbt_project_evaluator.get_metrics()
}}

View File

@@ -1,7 +1,7 @@
with relationships as (
{{
get_relationships("nodes")
dbt_project_evaluator.get_relationships("nodes")
}}
),

View File

@@ -1,4 +1,4 @@
{{
get_nodes()
dbt_project_evaluator.get_nodes()
}}

View File

@@ -1,4 +1,4 @@
{{
get_sources()
dbt_project_evaluator.get_sources()
}}

View File

@@ -8,7 +8,7 @@
{% endfor %}
with vars_folders_table as (
{{ loop_vars(vars_folders) }}
{{ dbt_project_evaluator.loop_vars(vars_folders) }}
)
select

View File

@@ -8,7 +8,7 @@
{% endfor %}
with vars_prefix_table as (
{{ loop_vars(vars_prefix) }}
{{ dbt_project_evaluator.loop_vars(vars_prefix) }}
),
parsed as (