Skip to content

Commit

Permalink
force property_id to string in combine_property_data macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dgitis committed Jul 21, 2024
1 parent f633263 commit 147db2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions macros/combine_property_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{%- set relation_suffix = relation.identifier|replace('events_intraday_', '') -%}
{%- if relation_suffix|int >= earliest_shard_to_retrieve|int -%}
create or replace table `{{target.project}}.{{var('combined_dataset')}}.events_intraday_{{relation_suffix}}{{property_id}}` clone `{{var('source_project')}}.analytics_{{property_id}}.events_intraday_{{relation_suffix}}`;
{% do modifications.append( {'source_partition': 'events_intraday_' + relation_suffix , 'destination_partition': 'events_intraday_' + relation_suffix + property_id } ) %}
{% do modifications.append( {'source_partition': 'events_intraday_' + relation_suffix , 'destination_partition': 'events_intraday_' + relation_suffix + property_id|string } ) %}
{%- endif -%}
{% endfor %}

Expand All @@ -33,7 +33,7 @@
{%- if relation_suffix|int >= earliest_shard_to_retrieve|int -%}
create or replace table `{{target.project}}.{{var('combined_dataset')}}.events_{{relation_suffix}}{{property_id}}` clone `{{var('source_project')}}.analytics_{{property_id}}.events_{{relation_suffix}}`;
drop table if exists `{{target.project}}.{{var('combined_dataset')}}.events_intraday_{{relation_suffix}}{{property_id}}`;
{% do modifications.append( {'source_partition': 'events_' + relation_suffix , 'destination_partition': 'events_' + relation_suffix + property_id } ) %}
{% do modifications.append( {'source_partition': 'events_' + relation_suffix , 'destination_partition': 'events_' + relation_suffix + property_id|string } ) %}
{%- endif -%}
{% endfor %}
{% elif this.name == 'base_ga4__pseudonymous_users' %}
Expand All @@ -44,7 +44,7 @@
{%- set relation_suffix = relation.identifier|replace('pseudonymous_users_', '') -%}
{%- if relation_suffix|int >= earliest_shard_to_retrieve|int -%}
create or replace table `{{target.project}}.{{var('combined_dataset')}}.pseudonymous_users_{{relation_suffix}}{{property_id}}` clone `{{var('source_project')}}.analytics_{{property_id}}.pseudonymous_users_{{relation_suffix}}`;
{% do modifications.append( {'source_partition': 'pseudonymous_users_' + relation_suffix , 'destination_partition': 'pseudonymous_users_' + relation_suffix + property_id } ) %}
{% do modifications.append( {'source_partition': 'pseudonymous_users_' + relation_suffix , 'destination_partition': 'pseudonymous_users_' + relation_suffix + property_id|string } ) %}
{%- endif -%}
{% endfor %}
{% elif this.name == 'base_ga4__users' %}
Expand All @@ -54,15 +54,15 @@
{%- set relation_suffix = relation.identifier|replace('users_', '') -%}
{%- if relation_suffix|int >= earliest_shard_to_retrieve|int -%}
create or replace table `{{target.project}}.{{var('combined_dataset')}}.users_{{relation_suffix}}{{property_id}}` clone `{{var('source_project')}}.analytics_{{property_id}}.users_{{relation_suffix}}`;
{% do modifications.append( {'source_partition': 'users_' + relation_suffix , 'destination_partition': 'users_' + relation_suffix + property_id } ) %}
{% do modifications.append( {'source_partition': 'users_' + relation_suffix , 'destination_partition': 'users_' + relation_suffix + property_id|string } ) %}
{%- endif -%}
{% endfor %}
{% endif %}
{%- endset -%}
{% do run_query(combine_specified_property_data_query) %}
{% if execute %}
{% for modification in modifications%}
{{ log("Cloned from `" ~ var('source_project') ~ ".analytics_" ~ property_id ~ "." ~ modification.source_partition ~"` to `" ~ target.project ~ "." ~ var('combined_dataset') ~ "." ~ modification.destination_partition ~"`", True) }}
{{ log("Cloned from `" ~ var('source_project') ~ ".analytics_" ~ property_id|string ~ "." ~ modification.source_partition ~"` to `" ~ target.project ~ "." ~ var('combined_dataset') ~ "." ~ modification.destination_partition ~"`", True) }}
{% endfor %}
{% endif %}
{% endfor %}
Expand Down
4 changes: 4 additions & 0 deletions package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
- package: dbt-labs/dbt_utils
version: 1.2.0
sha1_hash: dd1e1feb2d2bbce79e7a255cd309a60e6548df0b

0 comments on commit 147db2c

Please sign in to comment.