-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix initial dbt compile error (Close #69)
- Loading branch information
1 parent
23e665b
commit 51a6d22
Showing
4 changed files
with
134 additions
and
74 deletions.
There are no files selected for viewing
46 changes: 31 additions & 15 deletions
46
macros/incremental_hooks/get_incremental_manifest_status.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
{% macro get_session_lookback_limit(lower_limit) %} | ||
|
||
|
||
{# In case of not execute just return empty strings to avoid hitting database #} | ||
{% if not execute %} | ||
{{ return('')}} | ||
{% endif %} | ||
|
||
{% set limit_query %} | ||
select | ||
{{ snowplow_utils.timestamp_add( | ||
'day', | ||
-var("snowplow__session_lookback_days", 365), | ||
lower_limit) }} as session_lookback_limit | ||
{% if lower_limit == '' %} | ||
|
||
{% endset %} | ||
{% do exceptions.warn("Snowplow Warning: Macro get_session_lookback_limit lower_limit argument == ''. This is expected if you are compiling a fresh installation of the dbt-snowplow-* packages.") %} | ||
|
||
{% set results = run_query(limit_query) %} | ||
|
||
{% if execute %} | ||
{{ return('')}} | ||
|
||
{% set session_lookback_limit = snowplow_utils.cast_to_tstamp(results.columns[0].values()[0]) %} | ||
{% else %} | ||
|
||
{{ return(session_lookback_limit) }} | ||
{% set limit_query %} | ||
select | ||
{{ snowplow_utils.timestamp_add( | ||
'day', | ||
-var("snowplow__session_lookback_days", 365), | ||
lower_limit) }} as session_lookback_limit | ||
|
||
{% endif %} | ||
{% endset %} | ||
|
||
{% set results = run_query(limit_query) %} | ||
|
||
{% if execute %} | ||
|
||
{% set session_lookback_limit = snowplow_utils.cast_to_tstamp(results.columns[0].values()[0]) %} | ||
|
||
{{ return(session_lookback_limit) }} | ||
|
||
{% endif %} | ||
|
||
{% endif %} | ||
|
||
{% endmacro %} |
51 changes: 34 additions & 17 deletions
51
macros/incremental_hooks/return_base_new_event_limits.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,46 @@ | ||
{% macro return_base_new_event_limits(base_events_this_run) -%} | ||
|
||
{# In case of not execute just return empty strings to avoid hitting database #} | ||
{% if not execute %} | ||
{{ return(['','',''])}} | ||
{% endif %} | ||
|
||
{% set limit_query %} | ||
select | ||
lower_limit, | ||
upper_limit, | ||
{{ snowplow_utils.timestamp_add('day', | ||
-var("snowplow__max_session_days", 3), | ||
'lower_limit') }} as session_start_limit | ||
|
||
from {{ base_events_this_run }} | ||
{% endset %} | ||
{% set target_relation = adapter.get_relation( | ||
database=base_events_this_run.database, | ||
schema=base_events_this_run.schema, | ||
identifier=base_events_this_run.name) %} | ||
|
||
{% set results = run_query(limit_query) %} | ||
|
||
{% if execute %} | ||
{% if target_relation is not none %} | ||
|
||
{% set lower_limit = snowplow_utils.cast_to_tstamp(results.columns[0].values()[0]) %} | ||
{% set upper_limit = snowplow_utils.cast_to_tstamp(results.columns[1].values()[0]) %} | ||
{% set session_start_limit = snowplow_utils.cast_to_tstamp(results.columns[2].values()[0]) %} | ||
{% set limit_query %} | ||
select | ||
lower_limit, | ||
upper_limit, | ||
{{ snowplow_utils.timestamp_add('day', | ||
-var("snowplow__max_session_days", 3), | ||
'lower_limit') }} as session_start_limit | ||
|
||
{{ return([lower_limit, upper_limit, session_start_limit]) }} | ||
from {{ base_events_this_run }} | ||
{% endset %} | ||
|
||
{% set results = run_query(limit_query) %} | ||
|
||
{% if execute %} | ||
|
||
{% set lower_limit = snowplow_utils.cast_to_tstamp(results.columns[0].values()[0]) %} | ||
{% set upper_limit = snowplow_utils.cast_to_tstamp(results.columns[1].values()[0]) %} | ||
{% set session_start_limit = snowplow_utils.cast_to_tstamp(results.columns[2].values()[0]) %} | ||
|
||
{{ return([lower_limit, upper_limit, session_start_limit]) }} | ||
|
||
{% endif %} | ||
|
||
{% else %} | ||
|
||
{% do exceptions.warn("Snowplow Warning: " ~ base_events_this_run ~ " does not exist. This is expected if you are compiling a fresh installation of the dbt-snowplow-* packages.") %} | ||
|
||
{{ return(['','','']) }} | ||
|
||
{% endif %} | ||
|
||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters