Skip to content

Commit

Permalink
Add meta to seeds/snapshots (#237)
Browse files Browse the repository at this point in the history
* add meta to seeds/snapshots

* remove quotes - bigquery

* add parse_json

* type_array -> type_json
  • Loading branch information
nhrebinka authored Nov 2, 2022
1 parent c07c8b2 commit e640c06
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
9 changes: 6 additions & 3 deletions macros/upload_seeds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(6) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(7) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }}
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }},
{{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(10)) }}
from values
{% for seed in seeds -%}
(
Expand All @@ -31,7 +32,8 @@
'{{ seed.name }}', {# name #}
'{{ seed.package_name }}', {# package_name #}
'{{ seed.original_file_path | replace('\\', '\\\\') }}', {# path #}
'{{ seed.checksum.checksum }}' {# checksum #}
'{{ seed.checksum.checksum }}', {# checksum #}
'{{ tojson(seed.config.meta) }}' {# meta #}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand All @@ -55,7 +57,8 @@
'{{ seed.name }}', {# name #}
'{{ seed.package_name }}', {# package_name #}
'{{ seed.original_file_path | replace('\\', '\\\\') }}', {# path #}
'{{ seed.checksum.checksum }}' {# checksum #}
'{{ seed.checksum.checksum }}', {# checksum #}
parse_json('{{ tojson(seed.config.meta) }}') {# meta #}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand Down
9 changes: 6 additions & 3 deletions macros/upload_snapshots.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(8) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(9) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(10) }},
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }}
{{ adapter.dispatch('column_identifier', 'dbt_artifacts')(11) }},
{{ adapter.dispatch('parse_json', 'dbt_artifacts')(adapter.dispatch('column_identifier', 'dbt_artifacts')(12)) }}
from values
{% for snapshot in snapshots -%}
(
Expand All @@ -36,7 +37,8 @@
'{{ snapshot.package_name }}', {# package_name #}
'{{ snapshot.original_file_path | replace('\\', '\\\\') }}', {# path #}
'{{ snapshot.checksum.checksum }}', {# checksum #}
'{{ snapshot.config.strategy }}' {# strategy #}
'{{ snapshot.config.strategy }}', {# strategy #}
'{{ tojson(snapshot.config.meta) }}' {# meta #}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand All @@ -62,7 +64,8 @@
'{{ snapshot.package_name }}', {# package_name #}
'{{ snapshot.original_file_path | replace('\\', '\\\\') }}', {# path #}
'{{ snapshot.checksum.checksum }}', {# checksum #}
'{{ snapshot.config.strategy }}' {# strategy #}
'{{ snapshot.config.strategy }}', {# strategy #}
parse_json('{{ tojson(snapshot.config.meta) }}') {# meta #}
)
{%- if not loop.last %},{%- endif %}
{%- endfor %}
Expand Down
3 changes: 2 additions & 1 deletion models/dim_dbt__seeds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ seeds as (
name,
package_name,
path,
checksum
checksum,
meta
from base

)
Expand Down
3 changes: 2 additions & 1 deletion models/dim_dbt__snapshots.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ snapshots as (
package_name,
path,
checksum,
strategy
strategy,
meta
from base

)
Expand Down
3 changes: 2 additions & 1 deletion models/sources/seeds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ select
cast(null as {{ type_string() }}) as name,
cast(null as {{ type_string() }}) as package_name,
cast(null as {{ type_string() }}) as path,
cast(null as {{ type_string() }}) as checksum
cast(null as {{ type_string() }}) as checksum,
cast(null as {{ type_json() }}) as meta
from dummy_cte
where 1 = 0
3 changes: 2 additions & 1 deletion models/sources/snapshots.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ select
cast(null as {{ type_string() }}) as package_name,
cast(null as {{ type_string() }}) as path,
cast(null as {{ type_string() }}) as checksum,
cast(null as {{ type_string() }}) as strategy
cast(null as {{ type_string() }}) as strategy,
cast(null as {{ type_json() }}) as meta
from dummy_cte
where 1 = 0
3 changes: 2 additions & 1 deletion models/staging/stg_dbt__seeds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ enhanced as (
name,
package_name,
path,
checksum
checksum,
meta
from base

)
Expand Down
3 changes: 2 additions & 1 deletion models/staging/stg_dbt__snapshots.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ enhanced as (
package_name,
path,
checksum,
strategy
strategy,
meta
from base

)
Expand Down

0 comments on commit e640c06

Please sign in to comment.