Skip to content

Commit

Permalink
Merge pull request #26 from fivetran/feature/standardized-billing-lin…
Browse files Browse the repository at this point in the history
…e-item-model

Feature/standardized billing line item model
  • Loading branch information
fivetran-reneeli authored Aug 14, 2024
2 parents 8f4a421 + 35680eb commit 6a7c1cc
Show file tree
Hide file tree
Showing 16 changed files with 415 additions and 60 deletions.
43 changes: 11 additions & 32 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,27 @@
**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:**
**Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:**
<!--- Copy/paste the CHANGELOG for this version below. -->

## 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)
- [ ] dbt run –full-refresh && dbt test
- [ ] dbt run (if incremental models are present) && dbt test

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
- [ ] The appropriate issue has been linked, tagged, and properly assigned
- [ ] All necessary documentation and version upgrades have been applied
<!--- Be sure to update the package version in the dbt_project.yml, integration_tests/dbt_project.yml, and README if necessary. -->
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)
- [ ] BuildKite integration tests are passing
- [ ] Detailed validation steps have been provided below

### 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.
Please share any and all of your validation steps:
<!--- 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:
:dancer:
13 changes: 13 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'auto release'
on:
pull_request:
types:
- closed
branches:
- main

jobs:
call-workflow-passing-data:
if: github.event.pull_request.merged
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@main
secrets: inherit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ target/
dbt_modules/
logs/
dbt_packages/
env/
package-lock.yml

### MacOS ###
.DS_Store
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# dbt_recurly v0.UPDATE.UPDATE
# dbt_recurly v0.4.0

## Under the Hood:
[PR #26](https://github.com/fivetran/dbt_recurly/pull/26) includes the following breaking changes:

## Feature Updates
- Addition of the `recurly__line_item_enhanced` model. This model constructs a comprehensive, denormalized analytical table that enables reporting on key revenue, subscription, customer, and product metrics from your billing platform. It’s designed to align with the schema of the `*__line_item_enhanced` model found in Recurly, Recharge, Stripe, Shopify, and Zuora, offering standardized reporting across various billing platforms. To see the kinds of insights this model can generate, explore example visualizations in the [Fivetran Billing Model Streamlit App](https://fivetran-billing-model.streamlit.app/). Visit the app for more details.
- This model is currently disabled by default. You may enable it by setting the `recurly__standardized_billing_model_enabled` as `true` in your `dbt_project.yml`.

## Under the Hood:
- Added consistency test within integration_tests for the `recurly__line_item_enhanced` model.
- Included auto-releaser GitHub Actions workflow to automate future releases.
- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job.
- Updated the pull request [templates](/.github).
- Updated the pull request templates.

# dbt_recurly v0.3.2
## 🪲 Bug Fixes 🔧
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Generate a metrics tables allow you to better understand your account activity over time or at a customer level. These time-based metrics are available on a daily level.
- Generates a comprehensive data dictionary of your source and modeled Recurly data through the [dbt docs site](https://fivetran.github.io/dbt_recurly/).

<!--section="recurly_transformation_model"-->
The following table provides a detailed list of all models materialized within this package by default.
> TIP: See more details about these models in the package's [dbt docs site](https://fivetran.github.io/dbt_recurly/#!/overview?g_v=1).
Expand All @@ -33,6 +34,18 @@ The following table provides a detailed list of all models materialized within t
| [recurly__churn_analysis](https://fivetran.github.io/dbt_recurly/#!/model/model.recurly.recurly__churn_analysis) | Each record represents a subscription and their churn status and details. |
| [recurly__monthly_recurring_revenue](https://fivetran.github.io/dbt_recurly/#!/model/model.recurly.recurly__monthly_recurring_revenue) | Each record represents an account and MRR generated on a monthly basis. |
| [recurly__subscription_overview](https://fivetran.github.io/dbt_recurly/#!/model/model.recurly.recurly__subscription_overview) | Each record represents a subscription, enriched with metrics about time, revenue, state, and period. |
| [recurly__line_item_enhanced](https://fivetran.github.io/dbt_recurly/#!/model/model.recurly.recurly__line_item_enhanced) | This model constructs a comprehensive, denormalized analytical table that enables reporting on key revenue, subscription, customer, and product metrics from your billing platform. It’s designed to align with the schema of the `*__line_item_enhanced` model found in Recurly, Recharge, Stripe, Shopify, and Zuora, offering standardized reporting across various billing platforms. To see the kinds of insights this model can generate, explore example visualizations in the [Fivetran Billing Model Streamlit App](https://fivetran-billing-model.streamlit.app/). Visit the app for more details. |

## Example Visualizations
Curious what these models can do? Check out example visualizations from the [recurly__line_item_enhanced](https://fivetran.github.io/dbt_recurly/#!/model/model.recurly.recurly__line_item_enhanced) model in the [Fivetran Billing Model Streamlit App](https://fivetran-billing-model.streamlit.app/), and see how you can use these models in your own reporting. Below is a screenshot of an example report—explore the app for more.

<p align="center">
<a href="https://fivetran-billing-model.streamlit.app/">
<img src="https://raw.githubusercontent.com/fivetran/dbt_recurly/main/images/streamlit_example.png" alt="Streamlit Billing Model App" width="75%">
</a>
</p>

<!--section-end-->

# 🎯 How do I use the dbt package?
## Step 1: Prerequisites
Expand All @@ -54,7 +67,7 @@ Include the following recurly_source package version in your `packages.yml` file
```yaml
packages:
- package: fivetran/recurly
version: [">=0.3.0", "<0.4.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.4.0", "<0.5.0"]
```

Do NOT include the `recurly_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
Expand All @@ -80,7 +93,15 @@ vars:
```
## (Optional) Step 5: Additional configurations
<details><summary>Expand to view configurations</summary>
<details open><summary>Expand to view configurations</summary>

### Enabling Standardized Billing Model
This package contains the `recurly__line_item_enhanced` model which constructs a comprehensive, denormalized analytical table that enables reporting on key revenue, subscription, customer, and product metrics from your billing platform. It’s designed to align with the schema of the `*__line_item_enhanced` model found in Recurly, Recharge, Stripe, Shopify, and Zuora, offering standardized reporting across various billing platforms. To see the kinds of insights this model can generate, explore example visualizations in the [Fivetran Billing Model Streamlit App](https://fivetran-billing-model.streamlit.app/). For the time being, this model is disabled by default. If you would like to enable this model you will need to adjust the `recurly__standardized_billing_model_enabled` variable to be `true` within your `dbt_project.yml`:

```yml
vars:
recurly__standardized_billing_model_enabled: true # false by default.
```

### Passing Through Additional Fields
This package includes all source columns defined in the macros folder. You can add more columns using our pass-through column variables. These variables allow for the pass-through fields to be aliased (`alias`) and casted (`transform_sql`) if desired, but not required. Datatype casting is configured via a sql snippet within the `transform_sql` key. You may add the desired sql while omitting the `as field_name` at the end and your custom pass-though fields will be casted accordingly. Use the below format for declaring the respective pass-through variables:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'recurly'
version: '0.3.2'
version: '0.4.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]

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

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions 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.

Binary file added images/streamlit_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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: recurly_integrations_tests
schema: recurly_integrations_tests_1
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: recurly_integrations_tests
schema: recurly_integrations_tests_1
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: recurly_integrations_tests
schema: recurly_integrations_tests_1
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: recurly_integrations_tests
schema: recurly_integrations_tests_1
threads: 8
databricks:
catalog: null
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: recurly_integrations_tests
schema: recurly_integrations_tests_1
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
10 changes: 8 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'recurly_integration_tests'
version: '0.3.2'
version: '0.4.0'
profile: 'integration_tests'
config-version: 2

vars:
recurly_schema: recurly_integrations_tests
recurly_schema: recurly_integrations_tests_1
recurly_source:
account_balance_history_identifier: "account_balance_history_data"
account_history_identifier: "account_history_data"
Expand All @@ -25,6 +25,10 @@ vars:
transaction_identifier: "transaction_data"
transaction_subscription_identifier: "transaction_subscription_data"

# For use with validations
models:
+schema: "recurly_{{ var('directed_schema','dev') }}"

dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
Expand Down Expand Up @@ -61,6 +65,7 @@ seeds:
tax: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
line_item_history_data:
+column_types:
subscription_id: "{{ 'string' if target.name in ('bigquery', 'spark', 'databricks') else 'varchar' }}"
discount: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
unit_amount: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
subtotal: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
Expand Down Expand Up @@ -89,6 +94,7 @@ seeds:
quantity: "{{ 'INT64' if target.type == 'bigquery' else 'bigint' }}"
subscription_history_data:
+column_types:
id: "{{ 'string' if target.name in ('bigquery', 'spark', 'databricks') else 'varchar' }}"
paused_at: timestamp
unit_amount: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
add_ons_total: "{{ 'FLOAT64' if target.type == 'bigquery' else 'float' }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select *
from {{ target.schema }}_recurly_prod.recurly__line_item_enhanced
),

dev as (
select *
from {{ target.schema }}_recurly_dev.recurly__line_item_enhanced
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final
Loading

0 comments on commit 6a7c1cc

Please sign in to comment.