Skip to content

Commit

Permalink
Merge pull request #67 from fivetran/bugfix/allow_empty_data_model
Browse files Browse the repository at this point in the history
Bugfix/allow empty data model
  • Loading branch information
fivetran-joemarkiewicz authored May 16, 2023
2 parents 4be5791 + 7dcb566 commit 5d4f43d
Show file tree
Hide file tree
Showing 34 changed files with 115 additions and 127 deletions.
2 changes: 2 additions & 0 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ dbt run --target "$db" --full-refresh
dbt test --target "$db"
dbt run --vars '{stripe__using_invoice_line_sub_filter: false, stripe__using_credit_notes: true, stripe__using_price: false, stripe__using_subscription_history: false}' --full-refresh --target "$db"
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
51 changes: 51 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## PR Overview
**This PR will address the following Issue/Feature:**

**This PR will result in the following new package version:**
<!--- Please add details around your decision for breaking vs non-breaking version upgrade. If this is a breaking change, were backwards-compatible options explored? -->

**Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:**

## PR Checklist
### Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
- [ ] dbt compile
- [ ] dbt run –full-refresh
- [ ] dbt run
- [ ] dbt test
- [ ] dbt run –vars (if applicable)

Before marking this PR as "ready for review" the following have been applied:
- [ ] The appropriate issue has been linked and tagged
- [ ] You are assigned to the corresponding issue and this PR
- [ ] BuildKite integration tests are passing

### Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
- [ ] You have validated these changes and assure this PR will address the respective Issue/Feature.
- [ ] You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
- [ ] You have provided details below around the validation steps performed to gain confidence in these changes.
<!--- Provide the steps you took to validate your changes below. -->

### Standard Updates
Please acknowledge that your PR contains the following standard updates:
- Package versioning has been appropriately indexed in the following locations:
- [ ] indexed within dbt_project.yml
- [ ] indexed within integration_tests/dbt_project.yml
- [ ] CHANGELOG has individual entries for each respective change in this PR
<!--- If there is a parallel upstream change, remember to reference the corresponding CHANGELOG as an individual entry. -->
- [ ] README updates have been applied (if applicable)
<!--- Remember to check the following README locations for common updates. →
<!--- Suggested install range (needed for breaking changes) →
<!--- Dependency matrix is appropriately updated (if applicable) →
<!--- New variable documentation (if applicable) -->
- [ ] DECISIONLOG updates have been updated (if applicable)
- [ ] Appropriate yml documentation has been added (if applicable)

### dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)

### If you had to summarize this PR in an emoji, which would it be?
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:
51 changes: 16 additions & 35 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
**Are you a current Fivetran customer?**
<!--- Please tell us your name, title and company -->
**Please provide your name and company**

**What change(s) does this PR introduce?**
<!--- Describe what changes your PR introduces to the package and how to leverage this new feature. -->
**Link the issue/feature request which this PR is meant to address**
<!--- If an issue was not created, please create one first so we may discuss the PR prior to opening one. -->

**Did you update the CHANGELOG?**
**Detail what changes this PR introduces and how this addresses the issue/feature request linked above.**

**How did you validate the changes introduced within this PR?**

**Which warehouse did you use to develop these changes?**

**Did you update the CHANGELOG?**
<!--- Please update the new package version’s CHANGELOG entry detailing the changes included in this PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Does this PR introduce a breaking change?**
<!--- Does this PR introduce changes that will cause current package users' jobs to fail or require a `--full-refresh`? -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes (please provide breaking change details below.)
- [ ] No (please provide an explanation as to how the change is non-breaking below.)

**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
<!--- The dbt_project.yml and the integration_tests/dbt_project.yml files contain the version number. Be sure to upgrade it accordingly -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Is this PR in response to a previously created Bug or Feature Request**
<!--- If an Issue was created it is helpful to track the progress by linking it in the PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes, Issue/Feature [link bug/feature number here]
- [ ] No

**How did you test the PR changes?**
<!--- Proof of testing is required in order for the PR to be approved. -->
<!--- To check a box, remove the space and insert an x in the box (eg. [x] BuildKite). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] BuildKite <!--- BuildKite testing is only applicable to Fivetran employees. -->
- [ ] Local (please provide additional testing details below)

**Select which warehouse(s) were used to test the PR**
<!--- To check a warehouse remove the space and insert an x in the box (eg. [x] Bigquery). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] BigQuery
- [ ] Redshift
- [ ] Snowflake
- [ ] Postgres
- [ ] Databricks
- [ ] Other (provide details below)

**Provide an emoji that best describes your current mood**
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:

**Feedback**

We are so excited you decided to contribute to the Fivetran community dbt package! We continue to work to improve the packages and would greatly appreciate your [feedback](https://www.surveymonkey.com/r/DQ7K7WW) on our existing dbt packages or what you'd like to see next.

**PR Template**
- [Community Pull Request Template](?expand=1&template=pull_request_template.md) (default)

- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# dbt_stripe_source v0.9.3
v0.9.3 includes the following updates:
## Under the Hood:
- [PR #67](https://github.com/fivetran/dbt_stripe_source/pull/67) moves the live_mode predicate to the non *_tmp staging models.
- This move is necessary due to the [0.4.3 release of fivetran_utils](https://github.com/fivetran/dbt_fivetran_utils/releases/tag/v0.4.3), which infers if the source table a package is present, and if not the package will create an empty table to ensure the downstream transformations succeed. Previously the Stripe package wasn't compatible because of where the live_mode predicate existed. In the case there will be an empty data model created, we needed to move the predicate so that the queries and downstream models will still run correctly.
- [PR #66](https://github.com/fivetran/dbt_stripe_source/pull/66) incorporates the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job and updates the pull request [templates](/.github).
# dbt_stripe_source v0.9.2
PR [#64](https://github.com/fivetran/dbt_stripe_source/pull/64) includes the following updates:
## Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ dispatch:
search_order: ['spark_utils', 'dbt_utils']
```
## Step 2: Install the package
Include the following stripe_source package version in your `packages.yml` file.
## Step 2: Install the package (skip if also using the `stripe` transformation package)
If you are **not** using the [Stripe transformation package](https://github.com/fivetran/dbt_stripe), include the following package version in your `packages.yml` file. If you are installing the transform package, the source package is automatically installed as a dependency.
> TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.
```yaml
packages:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'stripe_source'
version: '0.9.2'
version: '0.9.3'
require-dbt-version: [">=1.3.0", "<2.0.0"]

models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: stripe_source_integrations_tests_1
schema: stripe_source_integrations_tests_3
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: stripe_source_integrations_tests_1
schema: stripe_source_integrations_tests_3
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: stripe_source_integrations_tests_1
schema: stripe_source_integrations_tests_3
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: stripe_source_integrations_tests_1
schema: stripe_source_integrations_tests_3
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: stripe_source_integrations_tests_1
schema: stripe_source_integrations_tests_3
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
config-version: 2

name: 'stripe_source_integration_tests'
version: '0.9.2'
version: '0.9.3'


profile: 'integration_tests'

vars:
stripe_schema: stripe_source_integrations_tests_1
stripe_schema: stripe_source_integrations_tests_3
stripe_source:
stripe_account_identifier: "account_data"
stripe_group_identifier: "group_data"
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__charge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
2 changes: 2 additions & 0 deletions models/stg_stripe__credit_note.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ final as (
invoice_id,
refund_id,
source_relation

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__credit_note_line_item.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ final as (
source_relation

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
3 changes: 3 additions & 0 deletions models/stg_stripe__customer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
and
not coalesce(is_deleted, false)
)

select *
Expand Down
3 changes: 2 additions & 1 deletion models/stg_stripe__invoice.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ final as (
{% endif %}

from fields
where not coalesce(is_deleted, false)
{{ livemode_predicate() }}
and not coalesce(is_deleted, false)
)

select *
Expand Down
4 changes: 3 additions & 1 deletion models/stg_stripe__invoice_line_item.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}

{% if var('stripe__using_invoice_line_sub_filter', true) %}
where id not like 'sub%' -- ids starting with 'sub' are temporary and are replaced by permanent ids starting with 'sli'
and id not like 'sub%' -- ids starting with 'sub' are temporary and are replaced by permanent ids starting with 'sli'
{% endif %}

)

select *
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__payment_intent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__payment_method.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__payout.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
1 change: 1 addition & 0 deletions models/stg_stripe__price_plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
)

select *
Expand Down
4 changes: 4 additions & 0 deletions models/stg_stripe__subscription.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ final as (
{% endif %}

from fields
{{ livemode_predicate() }}
{% if var('stripe__using_subscription_history', does_table_exist('subscription_history')) %}
and coalesce(_fivetran_active, true)
{% endif %}
)

select *
Expand Down
8 changes: 1 addition & 7 deletions models/tmp/stg_stripe__charge_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
select * from (

{{
fivetran_utils.union_data(
table_identifier='charge',
Expand All @@ -11,8 +9,4 @@ select * from (
union_schema_variable='stripe_union_schemas',
union_database_variable='stripe_union_databases'
)
}}

) as fields

{{ livemode_predicate() }}
}}
6 changes: 0 additions & 6 deletions models/tmp/stg_stripe__credit_note_line_item_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{ config(enabled=var('stripe__using_credit_notes', False)) }}

select * from (

{{
fivetran_utils.union_data(
table_identifier='credit_note_line_item',
Expand All @@ -14,7 +12,3 @@ select * from (
union_database_variable='stripe_union_databases'
)
}}

) as fields

{{ livemode_predicate() }}
8 changes: 1 addition & 7 deletions models/tmp/stg_stripe__credit_note_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{ config(enabled=var('stripe__using_credit_notes', False)) }}

select * from (

{{
fivetran_utils.union_data(
table_identifier='credit_note',
Expand All @@ -13,8 +11,4 @@ select * from (
union_schema_variable='stripe_union_schemas',
union_database_variable='stripe_union_databases'
)
}}

) as fields

{{ livemode_predicate() }}
}}
7 changes: 0 additions & 7 deletions models/tmp/stg_stripe__customer_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
select * from (

{{
fivetran_utils.union_data(
Expand All @@ -12,9 +11,3 @@ select * from (
union_database_variable='stripe_union_databases'
)
}}

) as fields

{{ livemode_predicate() }}
and
not coalesce(is_deleted, false)
Loading

0 comments on commit 5d4f43d

Please sign in to comment.