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
171ad18
commit 7bfa1d9
Showing
3 changed files
with
107 additions
and
55 deletions.
There are no files selected for viewing
48 changes: 32 additions & 16 deletions
48
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
53 changes: 36 additions & 17 deletions
53
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,48 @@ | ||
{% 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 }} | ||
|
||
{% set target_relation = adapter.get_relation( | ||
database=base_events_this_run.database, | ||
schema=base_events_this_run.schema, | ||
identifier=base_events_this_run.name) %} | ||
|
||
{% if target_relation is not none %} | ||
|
||
{% 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 results = run_query(limit_query) %} | ||
|
||
{% if execute %} | ||
{% 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]) %} | ||
|
||
{% 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]) }} | ||
|
||
{{ 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.") %} | ||
|
||
{% set dummy_limit = snowplow_utils.cast_to_tstamp('9999-01-01 00:00:00') %} | ||
|
||
{{ return([dummy_limit, dummy_limit, dummy_limit]) }} | ||
|
||
{% 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