-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from TasmanAnalytics/release/v1.0
Release/v1.0
- Loading branch information
Showing
31 changed files
with
1,358 additions
and
402 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
|
||
# Automatically cancel any previous runs of this workflow | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci-check-snowflake: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./integration_tests | ||
env: | ||
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} | ||
SNOWFLAKE_USER_CI: ${{ secrets.SNOWFLAKE_CI_USER }} | ||
SNOWFLAKE_PASSWORD_CI: ${{ secrets.SNOWFLAKE_CI_USER_PASSWORD }} | ||
SNOWFLAKE_DATABASE_CI: DBT_PACKAGE_CI | ||
SNOWFLAKE_ROLE_CI: PACKAGE_CI_ROLE | ||
SNOWFLAKE_WAREHOUSE_CI: PACKAGE_CI_WH | ||
SNOWFLAKE_SCHEMA_CI: DBT_CI_${{github.event.number}}_${{ github.actor }} # Creates a unique schema for each PR | ||
steps: | ||
- name: Checkout branch | ||
id: checkout-branch | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Poetry | ||
id: install-poetry | ||
run: | | ||
pipx install poetry | ||
- name: setup-python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
cache: 'poetry' # Auto cache based on poetry.lock | ||
|
||
- name: Install python deps | ||
id: install-python-deps | ||
run: | | ||
poetry install | ||
- name: Install dbt deps | ||
id: install-dbt-deps | ||
run: | | ||
poetry run dbt deps | ||
- name: Check dbt compiles and CI Profiles work | ||
id: check-dbt-ci-profiles-work | ||
run: | | ||
poetry run dbt debug --target snowflake-ci | ||
- name: dbt seed on Snowflake | ||
id: dbt-seed-snowflake | ||
run: | | ||
poetry run dbt seed --target snowflake-ci | ||
- name: dbt run on Snowflake | ||
id: dbt-run-snowflake | ||
run: | | ||
poetry run dbt run --full-refresh --target snowflake-ci | ||
- name: dbt test on Snowflake | ||
id: dbt-test-snowflake | ||
run: | | ||
poetry run dbt test --target snowflake-ci |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -10,4 +10,5 @@ log-path: "logs" | |
|
||
models: | ||
tasman_dbt_revenuecat: | ||
+materialized: table | ||
+materialized: table | ||
+schema: revenuecat |
File renamed without changes.
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,5 +1,3 @@ | ||
packages: | ||
- local: ../ | ||
- package: dbt-labs/dbt_utils | ||
version: 1.1.1 | ||
sha1_hash: 7ddc9cc629d204960cdbec3d712481aace9ed5d3 | ||
sha1_hash: de2deba3d66ce03d8c02949013650cc9b94f6030 |
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,5 +1,2 @@ | ||
packages: | ||
- local: ../ | ||
|
||
- package: dbt-labs/dbt_utils | ||
version: 1.1.1 | ||
- local: ../ |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tasman_integration_tests: | ||
outputs: | ||
snowflake-ci: | ||
account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}" | ||
client_session_keep_alive: true | ||
database: "{{ env_var('SNOWFLAKE_DATABASE_CI') }}" | ||
user: "{{ env_var('SNOWFLAKE_USER_CI') }}" | ||
password: "{{ env_var('SNOWFLAKE_PASSWORD_CI') }}" | ||
role: "{{ env_var('SNOWFLAKE_ROLE_CI') }}" | ||
schema: "{{ env_var('SNOWFLAKE_SCHEMA_CI') }}" | ||
warehouse: "{{ env_var('SNOWFLAKE_WAREHOUSE_CI') }}" | ||
threads: 12 | ||
type: snowflake |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{% macro get_intervals_between(start_date, end_date, datepart) -%} | ||
{{ return(adapter.dispatch('get_intervals_between', 'tasman_dbt_revenuecat')(start_date, end_date, datepart)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__get_intervals_between(start_date, end_date, datepart) -%} | ||
{%- call statement('get_intervals_between', fetch_result=True) %} | ||
|
||
select {{ dbt.datediff(start_date, end_date, datepart) }} | ||
|
||
{%- endcall -%} | ||
|
||
{%- set value_list = load_result('get_intervals_between') -%} | ||
|
||
{%- if value_list and value_list['data'] -%} | ||
{%- set values = value_list['data'] | map(attribute=0) | list %} | ||
{{ return(values[0]) }} | ||
{%- else -%} | ||
{{ return(1) }} | ||
{%- endif -%} | ||
|
||
{%- endmacro %} | ||
|
||
|
||
|
||
|
||
{% macro date_spine(datepart, start_date, end_date) %} | ||
{{ return(adapter.dispatch('date_spine', 'tasman_dbt_revenuecat')(datepart, start_date, end_date)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__date_spine(datepart, start_date, end_date) %} | ||
|
||
|
||
{# call as follows: | ||
|
||
date_spine( | ||
"day", | ||
"to_date('01/01/2016', 'mm/dd/yyyy')", | ||
"dbt.dateadd(week, 1, current_date)" | ||
) #} | ||
|
||
|
||
with rawdata as ( | ||
|
||
{{tasman_dbt_revenuecat.generate_series( | ||
tasman_dbt_revenuecat.get_intervals_between(start_date, end_date, datepart) | ||
)}} | ||
|
||
), | ||
|
||
all_periods as ( | ||
|
||
select ( | ||
{{ | ||
dbt.dateadd( | ||
datepart, | ||
"row_number() over (order by 1) - 1", | ||
start_date | ||
) | ||
}} | ||
) as date_{{datepart}} | ||
from rawdata | ||
|
||
), | ||
|
||
filtered as ( | ||
|
||
select * | ||
from all_periods | ||
where date_{{datepart}} <= {{ end_date }} | ||
|
||
) | ||
|
||
select * from filtered | ||
|
||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% macro get_powers_of_two(upper_bound) %} | ||
{{ return(adapter.dispatch('get_powers_of_two', 'tasman_dbt_revenuecat')(upper_bound)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__get_powers_of_two(upper_bound) %} | ||
|
||
{% if upper_bound <= 0 %} | ||
{{ exceptions.raise_compiler_error("upper bound must be positive") }} | ||
{% endif %} | ||
|
||
{% for _ in range(1, 100) %} | ||
{% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %} | ||
{% endfor %} | ||
|
||
{% endmacro %} | ||
|
||
|
||
{% macro generate_series(upper_bound) %} | ||
{{ return(adapter.dispatch('generate_series', 'tasman_dbt_revenuecat')(upper_bound)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__generate_series(upper_bound) %} | ||
|
||
{% set n = tasman_dbt_revenuecat.get_powers_of_two(upper_bound) %} | ||
|
||
with p as ( | ||
select 0 as generated_number union all select 1 | ||
), unioned as ( | ||
|
||
select | ||
|
||
{% for i in range(n) %} | ||
p{{i}}.generated_number * power(2, {{i}}) | ||
{% if not loop.last %} + {% endif %} | ||
{% endfor %} | ||
+ 1 | ||
as generated_number | ||
|
||
from | ||
|
||
{% for i in range(n) %} | ||
p as p{{i}} | ||
{% if not loop.last %} cross join {% endif %} | ||
{% endfor %} | ||
|
||
) | ||
|
||
select * | ||
from unioned | ||
where generated_number <= {{upper_bound}} | ||
order by generated_number | ||
|
||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{%- macro generate_surrogate_key(field_list) -%} | ||
{{ return(adapter.dispatch('generate_surrogate_key', 'tasman_dbt_revenuecat')(field_list)) }} | ||
{% endmacro %} | ||
|
||
{%- macro default__generate_surrogate_key(field_list) -%} | ||
|
||
{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%} | ||
{%- set default_null_value = "" -%} | ||
{%- else -%} | ||
{%- set default_null_value = '_tasman_dbt_revenuecat_surrogate_key_null_' -%} | ||
{%- endif -%} | ||
|
||
{%- set fields = [] -%} | ||
|
||
{%- for field in field_list -%} | ||
|
||
{%- do fields.append( | ||
"coalesce(cast(" ~ field ~ " as " ~ dbt.type_string() ~ "), '" ~ default_null_value ~"')" | ||
) -%} | ||
|
||
{%- if not loop.last %} | ||
{%- do fields.append("'-'") -%} | ||
{%- endif -%} | ||
|
||
{%- endfor -%} | ||
|
||
{{ dbt.hash(dbt.concat(fields)) }} | ||
|
||
{%- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% macro get_single_value(query, default=none) %} | ||
{{ return(adapter.dispatch('get_single_value', 'tasman_dbt_revenuecat')(query, default)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__get_single_value(query, default) %} | ||
|
||
{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #} | ||
|
||
{%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%} | ||
|
||
{{ query }} | ||
|
||
{%- endcall -%} | ||
|
||
{%- if execute -%} | ||
|
||
{% set r = load_result('get_query_result').table.columns[0].values() %} | ||
{% if r | length == 0 %} | ||
{% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %} | ||
{% set sql_result = default %} | ||
{% else %} | ||
{% set sql_result = r[0] %} | ||
{% endif %} | ||
|
||
{%- else -%} | ||
|
||
{% set sql_result = default %} | ||
|
||
{%- endif -%} | ||
|
||
{% do return(sql_result) %} | ||
|
||
{% endmacro %} |
Oops, something went wrong.