Skip to content

Commit 2f792bb

Browse files
Merge pull request #78 from fivetran/release/v0.13.0
Release/v0.13.0
2 parents f98e84d + 7c6161c commit 2f792bb

22 files changed

+143
-61
lines changed

.buildkite/hooks/pre-command

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export CI_SNOWFLAKE_DBT_USER=$(gcloud secrets versions access latest --secret="C
2121
export CI_SNOWFLAKE_DBT_WAREHOUSE=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_WAREHOUSE" --project="dbt-package-testing-363917")
2222
export CI_DATABRICKS_DBT_HOST=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HOST" --project="dbt-package-testing-363917")
2323
export CI_DATABRICKS_DBT_HTTP_PATH=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HTTP_PATH" --project="dbt-package-testing-363917")
24-
export CI_DATABRICKS_DBT_TOKEN=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_TOKEN" --project="dbt-package-testing-363917")
24+
export CI_DATABRICKS_DBT_TOKEN=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_TOKEN" --project="dbt-package-testing-363917")
25+
export CI_DATABRICKS_DBT_CATALOG=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_CATALOG" --project="dbt-package-testing-363917")

.buildkite/pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ steps:
5858
commands: |
5959
bash .buildkite/scripts/run_models.sh redshift
6060
61-
- label: ":bricks: Run Tests - Databricks"
61+
- label: ":databricks: Run Tests - Databricks"
6262
key: "run_dbt_databricks"
6363
plugins:
6464
- docker#v3.13.0:
@@ -69,5 +69,6 @@ steps:
6969
- "CI_DATABRICKS_DBT_HOST"
7070
- "CI_DATABRICKS_DBT_HTTP_PATH"
7171
- "CI_DATABRICKS_DBT_TOKEN"
72+
- "CI_DATABRICKS_DBT_CATALOG"
7273
commands: |
7374
bash .buildkite/scripts/run_models.sh databricks

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ target/
33
dbt_modules/
44
logs/
55
env/
6-
dbt_packages/
6+
dbt_packages/
7+
package-lock.yml

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# dbt_stripe v0.13.0
2+
[PR #78](https://github.com/fivetran/dbt_stripe/pull/78) includes the following updates:
3+
4+
## 🚨 Breaking Changes 🚨
5+
- Renamed folder `stripe_reports` to `stripe_financial_reports` to be more descriptive of the contents.
6+
- ⚠️ If you are using folder names to scope out configs, runs, etc., you will need to update the folder name.
7+
8+
## Bug fixes
9+
- Updated model `int_stripe__date_spine` to accommodate cases when model `stripe__balance_transactions` has no records.
10+
- Previously, the date spine relied on `stripe__balance_transactions` to set date bounds, which caused errors if empty. Now, the model defaults to a one-month range in such cases.
11+
12+
## Under the hood
13+
- Updated structure of model `int_stripe__date_spine` for improved performance and maintainability.
14+
115
# dbt_stripe v0.12.0
216
[PR #75](https://github.com/fivetran/dbt_stripe/pull/75) includes the following updates:
317

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Include the following stripe package version in your `packages.yml` file:
6161
```yaml
6262
packages:
6363
- package: fivetran/stripe
64-
version: [">=0.12.0", "<0.13.0"]
64+
version: [">=0.13.0", "<0.14.0"]
6565
6666
```
6767
Do **NOT** include the `stripe_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.

dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
config-version: 2
22
name: 'stripe'
33

4-
version: '0.12.0'
4+
version: '0.13.0'
55
require-dbt-version: [">=1.3.0", "<2.0.0"]
66
models:
77
stripe:

docs/catalog.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/run_results.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

integration_tests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
target/
33
dbt_modules/
44
logs/
5-
.DS_Store
5+
.DS_Store
6+
package-lock.yml

integration_tests/ci/sample.profiles.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ integration_tests:
4545
schema: stripe_integrations_tests_11
4646
threads: 8
4747
databricks:
48-
catalog: null
48+
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
4949
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
5050
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
5151
schema: stripe_integrations_tests_11
52-
threads: 2
52+
threads: 8
5353
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
5454
type: databricks

integration_tests/dbt_project.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
config-version: 2
22

33
name: 'stripe_integration_tests'
4-
version: '0.12.0'
4+
version: '0.13.0'
55

66
profile: 'integration_tests'
77

8+
# For use with validations
9+
models:
10+
+schema: "stripe_{{ var('directed_schema','dev') }}"
11+
812
vars:
913
stripe_schema: stripe_integrations_tests_11
1014
stripe_source:

integration_tests/requirements.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
dbt-snowflake>=1.3.0,<2.0.0
2-
dbt-bigquery>=1.3.0,<2.0.0
3-
dbt-redshift>=1.3.0,<2.0.0
4-
dbt-postgres>=1.3.0,<2.0.0
5-
dbt-spark>=1.3.0,<2.0.0
6-
dbt-spark[PyHive]>=1.3.0,<2.0.0
7-
dbt-databricks>=1.3.0,<2.0.0
8-
9-
oscrypto @ git+https://github.com/wbond/oscrypto.git@d5f3437
1+
dbt-snowflake>=1.3.0,<1.8.0
2+
dbt-bigquery>=1.3.0,<1.8.0
3+
dbt-redshift>=1.3.0,<1.8.0
4+
dbt-postgres>=1.3.0,<1.8.0
5+
dbt-spark>=1.3.0,<1.8.0
6+
dbt-spark[PyHive]>=1.3.0,<1.8.0
7+
dbt-databricks>=1.3.0,<1.8.0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{ config(
2+
tags="fivetran_validations",
3+
enabled=var('fivetran_validation_tests_enabled', false)
4+
) }}
5+
6+
-- this test ensures the daily_overview end model matches the prior version
7+
-- and is aggregated on the date_index grain since the rollings totals will cause variation at the account_id grain
8+
-- the below iterates through the prod and dev names to reduce redudancy of logic
9+
with
10+
{% for prod_or_dev in ('prod', 'dev') %}
11+
{% set cols = adapter.get_columns_in_relation(ref('stripe__daily_overview')) %}
12+
{{ prod_or_dev }} as (
13+
select
14+
date_index,
15+
source_relation
16+
{% for col in cols if col.name not in ["account_id", "account_daily_id", "date_day", "date_week", "date_month", "date_year", "date_index", "source_relation"] %}
17+
, floor(sum({{ col.name }})) as summed_{{ col.name }} -- floor and sum is to keep consistency between dev and prod aggs
18+
{% endfor %}
19+
from {{ target.schema }}_stripe_{{ prod_or_dev }}.stripe__daily_overview
20+
group by 1,2 -- need to group to remove randomization stemming from rolling totals
21+
),
22+
{% endfor %}
23+
24+
final as (
25+
-- test will fail if any rows from prod are not found in dev
26+
(select * from prod
27+
except distinct
28+
select * from dev)
29+
30+
union all -- union since we only care if rows are produced
31+
32+
-- test will fail if any rows from dev are not found in prod
33+
(select * from dev
34+
except distinct
35+
select * from prod)
36+
)
37+
38+
select *
39+
from final
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{ config(
2+
tags="fivetran_validations",
3+
enabled=var('fivetran_validation_tests_enabled', false)
4+
) }}
5+
6+
-- this test is to make sure the rows counts are the same between versions
7+
with prod as (
8+
select count(*) as prod_rows
9+
from {{ target.schema }}_stripe_prod.stripe__daily_overview
10+
),
11+
12+
dev as (
13+
select count(*) as dev_rows
14+
from {{ target.schema }}_stripe_dev.stripe__daily_overview
15+
)
16+
17+
-- test will return values and fail if the row counts don't match
18+
select *
19+
from prod
20+
join dev
21+
on prod.prod_rows != dev.dev_rows
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{ config(
2+
tags="fivetran_validations",
3+
enabled=var('fivetran_validation_tests_enabled', false)
4+
) }}
5+
6+
-- this test is to make sure there is no fanout between the spine and the daily_overview
7+
with spine as (
8+
select count(*) as spine_count
9+
from {{ target.schema }}_stripe_dev.int_stripe__date_spine
10+
),
11+
12+
daily_overview as (
13+
select count(*) as daily_overview_count
14+
from {{ target.schema }}_stripe_dev.stripe__daily_overview
15+
)
16+
17+
-- test will return values and fail if the row counts don't match
18+
select *
19+
from spine
20+
join daily_overview
21+
on spine.spine_count != daily_overview.daily_overview_count

models/intermediate/int_stripe__account_daily.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ select
100100
from daily_account_balance_transactions
101101
left join daily_failed_charges
102102
on daily_account_balance_transactions.date_day = daily_failed_charges.date
103-
and daily_account_balance_transactions.source_relation = daily_failed_charges.source_relation
103+
and daily_account_balance_transactions.source_relation = daily_failed_charges.source_relation

models/intermediate/int_stripe__date_spine.sql

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,43 @@
1-
1+
-- depends_on: {{ ref('stripe__balance_transactions') }}
22
with spine as (
33

44
{% if execute %}
5-
{% set first_date_query %}
6-
select min( balance_transaction_created_at ) as min_date from {{ ref('stripe__balance_transactions') }}
7-
{% endset %}
8-
{% set first_date = run_query(first_date_query).columns[0][0]|string %}
9-
10-
{% if target.type == 'postgres' %}
11-
{% set first_date_adjust = "cast('" ~ first_date[0:10] ~ "' as date)" %}
125

13-
{% else %}
14-
{% set first_date_adjust = "'" ~ first_date[0:10] ~ "'" %}
6+
{%- set first_date_query %}
7+
select coalesce(
8+
min(cast(balance_transaction_created_at as date)),
9+
cast({{ dbt.dateadd("month", -1, "current_date") }} as date)
10+
) as min_date
11+
from {{ ref('stripe__balance_transactions') }}
12+
{% endset -%}
1513

16-
{% endif %}
17-
18-
{% else %} {% set first_date_adjust = "'2009-01-01'" %}
19-
{% endif %}
14+
{%- set first_date = dbt_utils.get_single_value(first_date_query) %}
2015

21-
{% if execute %}
2216
{% set last_date_query %}
23-
select max( balance_transaction_created_at ) as max_date from {{ ref('stripe__balance_transactions') }}
24-
{% endset %}
25-
26-
{% set current_date_query %}
27-
select current_date
17+
select coalesce(
18+
greatest(max(cast(balance_transaction_created_at as date)), cast(current_date as date)),
19+
cast(current_date as date)
20+
) as max_date
21+
from {{ ref('stripe__balance_transactions') }}
2822
{% endset %}
2923

30-
{% if run_query(current_date_query).columns[0][0]|string < run_query(last_date_query).columns[0][0]|string %}
31-
32-
{% set last_date = run_query(last_date_query).columns[0][0]|string %}
33-
34-
{% else %} {% set last_date = run_query(current_date_query).columns[0][0]|string %}
35-
{% endif %}
36-
37-
{% if target.type == 'postgres' %}
38-
{% set last_date_adjust = "cast('" ~ last_date[0:10] ~ "' as date)" %}
24+
{% set last_date = dbt_utils.get_single_value(last_date_query) %}
3925

4026
{% else %}
41-
{% set last_date_adjust = "'" ~ last_date[0:10] ~ "'" %}
4227

43-
{% endif %}
28+
{% set first_date = 'dbt.dateadd("month", -1, "current_date")' %}
29+
{% set last_date = 'dbt.current_timestamp_backcompat()' %}
30+
4431
{% endif %}
4532

4633
{{ dbt_utils.date_spine(
4734
datepart="day",
48-
start_date=first_date_adjust,
49-
end_date=dbt.dateadd("day", 1, last_date_adjust)
35+
start_date="cast('" ~ first_date ~ "' as date)",
36+
end_date=dbt.dateadd("day", 1, "cast('" ~ last_date ~ "' as date)")
5037
)
5138
}}
5239
),
5340

54-
balance_transactions as (
55-
56-
select *
57-
from {{ ref('stripe__balance_transactions') }}
58-
),
59-
6041
account as (
6142

6243
select *

0 commit comments

Comments
 (0)