Skip to content

Commit

Permalink
Merge pull request #415 from whiteh/bug/raw_code-deleted-from-model
Browse files Browse the repository at this point in the history
[Bug] Leave model intact when uploading
  • Loading branch information
jared-rimmer authored Jan 25, 2024
2 parents 486c5f6 + dff781b commit 81da1e4
Showing 1 changed file with 45 additions and 42 deletions.
87 changes: 45 additions & 42 deletions macros/upload_individual_datasets/upload_models.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand All @@ -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 %}
Expand Down

0 comments on commit 81da1e4

Please sign in to comment.