Skip to content

Commit

Permalink
latest_collector_tstamp to latest_selected_tstamp
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarSnowPlow authored and ilias1111 committed Nov 15, 2024
1 parent 4564fd1 commit 938a2ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions macros/users_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ select
{% elif user_id_context != '' %}
{{ '_'.join(user_id_context.split('_')[:-2]) }}[0]:{{user_id_field}}::string as {{ snake_user_id }}
{%- endif %}
, collector_tstamp as latest_collector_tstamp
, {{ var('snowplow__partition_key') }} as latest_selected_tstamp
-- Flat columns from event table
{% if flat_cols|length > 0 %}
{%- for col in flat_cols -%}
Expand Down Expand Up @@ -63,7 +63,7 @@ from
where
{{ snake_user_id }} is not null
qualify
row_number() over (partition by {{ snake_user_id }} order by latest_collector_tstamp desc) = 1
row_number() over (partition by {{ snake_user_id }} order by latest_selected_tstamp desc) = 1
{% endmacro %}


Expand Down Expand Up @@ -117,7 +117,7 @@ with defined_user_id as (
) -%}
{{ user_id_cont_coal[0] }} as {{ snake_user_id }}
{%- endif %}
, collector_tstamp as latest_collector_tstamp
, {{ var('snowplow__partition_key') }} as latest_selected_tstamp
-- Flat columns from event table
{% if flat_cols|length > 0 %}
{%- for col in flat_cols -%}
Expand Down Expand Up @@ -151,7 +151,7 @@ with defined_user_id as (
users_ordering as (
select
a.*
, row_number() over (partition by {{ snake_user_id }} order by latest_collector_tstamp desc) as rn
, row_number() over (partition by {{ snake_user_id }} order by latest_selected_tstamp desc) as rn
from
defined_user_id a
where
Expand Down Expand Up @@ -201,9 +201,9 @@ with defined_user_id as (
{% elif user_id_context != '' %}
{{ '_'.join(user_id_context.split('_')[:-2]) }}[0].{{ user_id_field }} as {{ snake_user_id }}
{%- endif %}
, collector_tstamp as latest_collector_tstamp
, {{ var('snowplow__partition_key') }} as latest_selected_tstamp
{% if target.type in ['databricks', 'spark'] -%}
, DATE(collector_tstamp) as latest_collector_tstamp_date
, DATE( {{ var('snowplow__partition_key') }}) as latest_selected_tstamp_date
{%- endif %}
-- Flat columns from event table
{% if flat_cols|length > 0 %}
Expand Down Expand Up @@ -233,7 +233,7 @@ with defined_user_id as (
users_ordering as (
select
a.*
, row_number() over (partition by {{ snake_user_id }} order by latest_collector_tstamp desc) as rn
, row_number() over (partition by {{ snake_user_id }} order by latest_selected_tstamp desc) as rn
from
defined_user_id a
where
Expand Down
4 changes: 2 additions & 2 deletions utils/snowplow_normalize_model_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@
tags = "snowplow_normalize_incremental",
materialized = "incremental",
unique_key = "{user_alias}",
upsert_date_key = "latest_collector_tstamp",
upsert_date_key = "latest_selected_tstamp",
partition_by = snowplow_utils.get_value_by_target_type(bigquery_val={{
"field": "latest_collector_tstamp",
"field": "latest_selected_tstamp",
"data_type": "timestamp"
}}, databricks_val='latest_collector_tstamp_date'),
sql_header=snowplow_utils.set_query_tag(var('snowplow__query_tag', 'snowplow_dbt')),
Expand Down

0 comments on commit 938a2ef

Please sign in to comment.