Skip to content

Commit a3c5753

Browse files
authored
Merge branch 'release/snowplow-attribution/0.5.0' into allow_multiple_transformation_options
2 parents d672f06 + 6b08705 commit a3c5753

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{#
2+
Copyright (c) 2024-present Snowplow Analytics Ltd. All rights reserved.
3+
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0,
4+
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0.
5+
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/
6+
#}
7+
8+
/* macro is for spark only */
9+
/* Macro to remove complexity from model "transform_paths" for building spark CTEs. */
10+
11+
{% macro build_ctes(path_transform_name, parameter, model_type) %}
12+
{{ return(adapter.dispatch('build_ctes', 'snowplow_attribution')(path_transform_name, parameter, model_type)) }}
13+
{% endmacro %}
14+
15+
{% macro default__build_ctes(path_transform_name, parameter, model_type) %}
16+
{% endmacro %}
17+
18+
{% macro spark__build_ctes(path_transform_name, parameter, model_type) %}
19+
20+
select
21+
customer_id,
22+
{% if model_type == 'conversions' %}
23+
cv_id,
24+
event_id,
25+
cv_tstamp,
26+
cv_type,
27+
cv_path_start_tstamp,
28+
revenue,
29+
{% endif %}
30+
channel_path,
31+
{% if path_transform_name == 'unique_path' %}
32+
{{ path_transformation('unique_path', field_alias='channel') }} as channel_transformed_path,
33+
{% elif path_transform_name == 'frequency_path' %}
34+
{{ exceptions.raise_compiler_error(
35+
"Snowplow Error: Frequency path is currently not supported by the model, please remove it from the variable and use this path transformation function in a custom model."
36+
) }}
37+
38+
{% elif path_transform_name == 'first_path' %}
39+
{{ path_transformation('first_path', field_alias='channel') }} as channel_transformed_path,
40+
41+
{% elif path_transform_name == 'exposure_path' %}
42+
{{ path_transformation('exposure_path', field_alias='channel') }} as channel_transformed_path,
43+
44+
{% elif path_transform_name == 'remove_if_not_all' %}
45+
{{ path_transformation('remove_if_not_all', parameter, 'channel') }} as channel_transformed_path,
46+
47+
{% elif path_transform_name == 'remove_if_last_and_not_all' %}
48+
{{ path_transformation('remove_if_last_and_not_all', parameter, 'channel') }} as channel_transformed_path,
49+
50+
{% else %}
51+
{%- do exceptions.raise_compiler_error("Snowplow Error: the path transform - '"+path_transform_name+"' - is not supported. Please refer to the Snowplow docs on tagging. Please use one of the following: exposure_path, first_path, frequency_path, remove_if_last_and_not_all, remove_if_not_all, unique_path") %}
52+
{% endif %}
53+
54+
campaign_path,
55+
{% if path_transform_name == 'unique_path' %}
56+
{{ path_transformation('unique_path', field_alias='campaign') }} as campaign_transformed_path
57+
58+
{% elif path_transform_name == 'frequency_path' %}
59+
{{ exceptions.raise_compiler_error(
60+
"Snowplow Error: Frequency path is currently not supported by the model, please remove it from the variable and use this path transformation function in a custom model."
61+
) }}
62+
63+
{% elif path_transform_name == 'first_path' %}
64+
{{ path_transformation('first_path', field_alias='campaign') }} as campaign_transformed_path
65+
66+
{% elif path_transform_name == 'exposure_path' %}
67+
{{ path_transformation('exposure_path', field_alias='campaign') }} as campaign_transformed_path
68+
69+
{% elif path_transform_name == 'remove_if_not_all' %}
70+
{{ path_transformation('remove_if_not_all', parameter, 'campaign') }} as campaign_transformed_path
71+
72+
{% elif path_transform_name == 'remove_if_last_and_not_all' %}
73+
{{ path_transformation('remove_if_last_and_not_all', parameter, 'campaign') }} as campaign_transformed_path
74+
75+
{% else %}
76+
{%- do exceptions.raise_compiler_error("Snowplow Error: the path transform - '"+path_transform_name+"' - is not supported. Please refer to the Snowplow docs on tagging. Please use one of the following: exposure_path, first_path, frequency_path, remove_if_last_and_not_all, remove_if_not_all, unique_path") %}
77+
{% endif %}
78+
79+
{% endmacro %}

macros/source_checks.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{% set is_below_limit = result[0][0] %}
3737
{% if is_below_limit == True %}
3838
{{ exceptions.raise_compiler_error("Snowplow Error: The timestamp of the last visit in the path source: " ~ last_path_tstamp ~
39-
" plus the snowplow__path_lookback_days " ~ var('snowplow__path_lookback_days') ~ " is lower than the timestamp of the last conversion in the conversion source" ~ last_processed_cv_tstamp ~
39+
" plus the snowplow__path_lookback_days " ~ var('snowplow__path_lookback_days') ~ " is lower than the timestamp of the last conversion in the conversion source" ~ last_cv_tstamp ~
4040
" Please make sure you have updated downstream sources before proceeding."
4141
) }}
4242
{% endif %}

0 commit comments

Comments
 (0)