diff --git a/macros/upload_individual_datasets/upload_models.sql b/macros/upload_individual_datasets/upload_models.sql index d8dc49fd..7570b06a 100644 --- a/macros/upload_individual_datasets/upload_models.sql +++ b/macros/upload_individual_datasets/upload_models.sql @@ -24,26 +24,27 @@ {{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(15)) }} from values {% for model in models -%} - {% do model.pop('raw_code', None) %} + {% set model_copy = model.copy() -%} + {% do model_copy.pop('raw_code', None) %} ( '{{ invocation_id }}', {# command_invocation_id #} - '{{ model.unique_id }}', {# node_id #} + '{{ model_copy.unique_id }}', {# node_id #} '{{ run_started_at }}', {# run_started_at #} - '{{ model.database }}', {# database #} - '{{ model.schema }}', {# schema #} - '{{ model.name }}', {# name #} - '{{ tojson(model.depends_on.nodes) | replace('\\', '\\\\') }}', {# depends_on_nodes #} - '{{ model.package_name }}', {# package_name #} - '{{ model.original_file_path | replace('\\', '\\\\') }}', {# path #} - '{{ model.checksum.checksum | replace('\\', '\\\\') }}', {# checksum #} - '{{ model.config.materialized }}', {# materialization #} - '{{ tojson(model.tags) }}', {# tags #} - '{{ tojson(model.config.meta) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"') }}', {# meta #} - '{{ model.alias }}', {# alias #} + '{{ model_copy.database }}', {# database #} + '{{ model_copy.schema }}', {# schema #} + '{{ model_copy.name }}', {# name #} + '{{ tojson(model_copy.depends_on.nodes) | replace('\\', '\\\\') }}', {# depends_on_nodes #} + '{{ model_copy.package_name }}', {# package_name #} + '{{ model_copy.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ model_copy.checksum.checksum | replace('\\', '\\\\') }}', {# checksum #} + '{{ model_copy.config.materialized }}', {# materialization #} + '{{ tojson(model_copy.tags) }}', {# tags #} + '{{ tojson(model_copy.config.meta) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"') }}', {# meta #} + '{{ model_copy.alias }}', {# alias #} {% if var('dbt_artifacts_exclude_all_results', false) %} null {% else %} - '{{ tojson(model) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"') }}' {# all_results #} + '{{ tojson(model_copy) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"') }}' {# all_results #} {% endif %} ) {%- if not loop.last %},{%- endif %} @@ -59,26 +60,27 @@ {% if models != [] %} {% set model_values %} {% for model in models -%} - {% do model.pop('raw_code', None) %} + {% set model_copy = model.copy() -%} + {% do model_copy.pop('raw_code', None) %} ( '{{ invocation_id }}', {# command_invocation_id #} - '{{ model.unique_id }}', {# node_id #} + '{{ model_copy.unique_id }}', {# node_id #} '{{ run_started_at }}', {# run_started_at #} - '{{ model.database }}', {# database #} - '{{ model.schema }}', {# schema #} - '{{ model.name }}', {# name #} - {{ tojson(model.depends_on.nodes) }}, {# depends_on_nodes #} - '{{ model.package_name }}', {# package_name #} - '{{ model.original_file_path | replace('\\', '\\\\') }}', {# path #} - '{{ model.checksum.checksum | replace('\\', '\\\\') }}', {# checksum #} - '{{ model.config.materialized }}', {# materialization #} - {{ tojson(model.tags) }}, {# tags #} - {{ adapter.dispatch('parse_json', 'dbt_artifacts')(tojson(model.config.meta)) }}, {# meta #} - '{{ model.alias }}', {# alias #} + '{{ model_copy.database }}', {# database #} + '{{ model_copy.schema }}', {# schema #} + '{{ model_copy.name }}', {# name #} + {{ tojson(model_copy.depends_on.nodes) }}, {# depends_on_nodes #} + '{{ model_copy.package_name }}', {# package_name #} + '{{ model_copy.original_file_path | replace('\\', '\\\\') }}', {# path #} + '{{ model_copy.checksum.checksum | replace('\\', '\\\\') }}', {# checksum #} + '{{ model_copy.config.materialized }}', {# materialization #} + {{ tojson(model_copy.tags) }}, {# tags #} + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(tojson(model_copy.config.meta)) }}, {# meta #} + '{{ model_copy.alias }}', {# alias #} {% if var('dbt_artifacts_exclude_all_results', false) %} null {% else %} - {{ adapter.dispatch('parse_json', 'dbt_artifacts')(tojson(model) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"')) }} {# all_results #} + {{ adapter.dispatch('parse_json', 'dbt_artifacts')(tojson(model_copy) | replace("\\", "\\\\") | replace("'","\\'") | replace('"', '\\"')) }} {# all_results #} {% endif %} ) {%- if not loop.last %},{%- endif %} @@ -94,26 +96,27 @@ {% if models != [] %} {% set model_values %} {% for model in models -%} - {% do model.pop('raw_code', None) %} + {% set model_copy = model.copy() -%} + {% do model_copy.pop('raw_code', None) %} ( '{{ invocation_id }}', {# command_invocation_id #} - '{{ model.unique_id }}', {# node_id #} + '{{ model_copy.unique_id }}', {# node_id #} '{{ run_started_at }}', {# run_started_at #} - '{{ model.database }}', {# database #} - '{{ model.schema }}', {# schema #} - '{{ model.name }}', {# name #} - '{{ tojson(model.depends_on.nodes) }}', {# depends_on_nodes #} - '{{ model.package_name }}', {# package_name #} - $${{ model.original_file_path | replace('\\', '\\\\') }}$$, {# path #} - '{{ model.checksum.checksum }}', {# checksum #} - '{{ model.config.materialized }}', {# materialization #} - '{{ tojson(model.tags) }}', {# tags #} - $${{ model.config.meta }}$$, {# meta #} - '{{ model.alias }}', {# alias #} + '{{ model_copy.database }}', {# database #} + '{{ model_copy.schema }}', {# schema #} + '{{ model_copy.name }}', {# name #} + '{{ tojson(model_copy.depends_on.nodes) }}', {# depends_on_nodes #} + '{{ model_copy.package_name }}', {# package_name #} + $${{ model_copy.original_file_path | replace('\\', '\\\\') }}$$, {# path #} + '{{ model_copy.checksum.checksum }}', {# checksum #} + '{{ model_copy.config.materialized }}', {# materialization #} + '{{ tojson(model_copy.tags) }}', {# tags #} + $${{ model_copy.config.meta }}$$, {# meta #} + '{{ model_copy.alias }}', {# alias #} {% if var('dbt_artifacts_exclude_all_results', false) %} null {% else %} - $${{ tojson(model) }}$$ {# all_results #} + $${{ tojson(model_copy) }}$$ {# all_results #} {% endif %} ) {%- if not loop.last %},{%- endif %}