Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.4.0 #10

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dbt deps
dbt seed --target "$db" --full-refresh
dbt run --target "$db" --full-refresh
dbt test --target "$db"
dbt run --vars '{using_twilio_call: false, using_twilio_messaging_service: false}' --target "$db" --full-refresh
dbt run --vars '{using_twilio_call: false, using_twilio_messaging_service: false, using_twilio_usage_record: false}' --target "$db" --full-refresh
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
3 changes: 3 additions & 0 deletions .quickstart/quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ table_variables:
- messaging_service
using_twilio_call:
- call
using_twilio_usage_record:
- usage_record


destination_configurations:
databricks:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# dbt_twilio v0.4.0

## Features
- Added the ability to disable the `USAGE_RECORD` source table via variable `using_twilio_usage_record` (default `true`). If disabled, downstream this will remove the `total_account_spend` field in `twilio__account_overview`. Refer to the [README](https://github.com/fivetran/dbt_twilio?tab=readme-ov-file#step-4-enablingdisabling-models) for more details.

## Under the Hood
- Removes references to unused models in `twilio__message_enhanced`.

# dbt_twilio v0.3.0

> _Note_: This release is a 🚨 **breaking change** 🚨 due to breaking changes introduced in the upstream twilio_source package [v0.3.0](https://github.com/fivetran/dbt_twilio_source/releases/tag/v0.3.0) release, where we explicitly cast the below fields as float types and remove any non-numerical characters.
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center">
# Twilio Transformation dbt Package ([Docs](https://fivetran.github.io/dbt_twilio/))

<p align="left">
<a alt="License"
href="https://github.com/fivetran/dbt_twilio_source/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a>
Expand All @@ -10,8 +12,6 @@
<img src="https://img.shields.io/badge/Contributions-welcome-blueviolet" /></a>
</p>


# Twilio Transformation dbt Package ([Docs](https://fivetran.github.io/dbt_twilio/))
## What does this dbt package do?

- Produces modeled tables that leverage Twilio data from [Fivetran's connector](https://fivetran.com/docs/applications/twilio) in the format described by [this ERD](https://fivetran.com/docs/applications/twilio#schemainformation) and builds off the output of our [Twilio source package](https://github.com/fivetran/dbt_twilio_source).
Expand Down Expand Up @@ -51,7 +51,7 @@ Include the following Twilio package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/twilio
version: [">=0.3.0", "<0.4.0"]
version: [">=0.4.0", "<0.5.0"]
```
### Step 3: Define database and schema variables
By default, this package runs using your destination and the `Twilio` schema. If this is not where your Twilio data is (for example, if your Twilio schema is named `twilio_fivetran`), add the following configuration to your root `dbt_project.yml` file:
Expand All @@ -72,6 +72,8 @@ By default, all variables are assumed to be `true`.
vars:
using_twilio_call: False # Disable this if not using call
using_twilio_messaging_service: False # Disable this if not using messaging_service
using_twilio_usage_record: False # Disable this if not using usage_record
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our standard way would be twilio__using_usage_record, but then I should also update using_twilio_call and using_twilio_messaging_service, which would require users who already have those variables configured to change it, which would be more of a hassle customer-experience wise.


```

### (Optional) Step 5: Additional configurations
Expand Down Expand Up @@ -124,7 +126,7 @@ This dbt package is dependent on the following dbt packages. These dependencies
```yml
packages:
- package: fivetran/twilio_source
version: [">=0.3.0", "<0.4.0"]
version: [">=0.4.0", "<0.5.0"]

- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]
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: 'twilio'
version: '0.3.0'
version: '0.4.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
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/manifest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/run_results.json

This file was deleted.

6 changes: 4 additions & 2 deletions integration_tests/dbt_project.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this change there is no need for a set of validation tests since this is not directly making any changes to the underlying model logic. However, would you be able to add the following model config so we can use it for review testing and future validation testing once we add it to this package.

models:
  +schema: "twilio_{{ var('directed_schema','dev') }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, thanks for dropping that config! i added

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'twilio_integration_tests'
version: '0.3.0'
version: '0.4.0'
config-version: 2
profile: 'integration_tests'

Expand All @@ -14,11 +14,13 @@ vars:
twilio_usage_record_identifier: "twilio_usage_record_data"
twilio_call_identifier: "twilio_call_data"
twilio_message_identifier: "twilio_message_data"

dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']

models:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a question: There weren't any validation tests added, so was this just for future use? Did we think it wouldn't have been useful to add a row comparison test given the changes weren't significant enough to the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Yup just for future use. No validation tests for this PR since this isn't really changing any model.

+schema: "twilio_{{ var('directed_schema','dev') }}"

seeds:
twilio_integration_tests:
+column_types:
Expand Down
2 changes: 1 addition & 1 deletion models/twilio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ models:
- name: price_unit
description: The currency unit in which the `price` is measured.
- name: total_account_spend
description: The total cost or price incurred by account across all resources used.
description: The total cost or price incurred by account across all resources used. Note this will only exist if the `using_twilio_usage_record` variable is set as true (default being true).

20 changes: 14 additions & 6 deletions models/twilio__account_overview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
with messages as (

select *
from {{ ref('int_twilio__messages')}}
from {{ ref('int_twilio__messages') }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these formatting changes to ensure we have consistent formatting!

),

account_history as (

select *
from {{ var('account_history')}}
),
from {{ var('account_history') }}
)

{% if var('using_twilio_usage_record', True) %}
,
usage_record as (

select *
from {{ var('usage_record')}}
from {{ var('usage_record') }}
)
{% endif %}

select
messages.account_id,
Expand Down Expand Up @@ -44,13 +47,18 @@ select
{% endfor %}

count(messages.message_id) as total_messages,
round( cast(sum(messages.price) as {{ dbt.type_numeric ()}}), 2) * -1 as total_messages_spend,
round( cast(sum(usage_record.price) as {{ dbt.type_numeric ()}}), 2) as total_account_spend
round( cast(sum(messages.price) as {{ dbt.type_numeric() }}), 2) * -1 as total_messages_spend

{% if var('using_twilio_usage_record', True) %}
, round( cast(sum(usage_record.price) as {{ dbt.type_numeric() }}), 2) as total_account_spend
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the documentation for this field here to add a disclaimer that this will only be present if the using_twilio_usage_record variable is defined as true (default being true).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

{% endif %}

from messages
{% if var('using_twilio_usage_record', True) %}
left join usage_record
on messages.account_id = usage_record.account_id
and messages.date_day = usage_record.start_date
{% endif %}
left join account_history
on messages.account_id = account_history.account_id

Expand Down
12 changes: 0 additions & 12 deletions models/twilio__message_enhanced.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ with messages as (
from {{ ref('int_twilio__messages') }}
),

incoming_phone_number as (

select *
from {{ var('incoming_phone_number')}}
),
Comment on lines -7 to -11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I didn't realize incoming phone number was included here as well even with it not being referenced. Thanks for removing!


addresses as (

select *
from {{ var('address')}}
),

{% if var('using_twilio_messaging_service', True) %}
messaging_service as (

Expand Down
8 changes: 6 additions & 2 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
packages:
- package: fivetran/twilio_source
version: [">=0.3.0", "<0.4.0"]
# - package: fivetran/twilio_source
# version: [">=0.3.0", "<0.4.0"]

- git: https://github.com/fivetran/dbt_twilio_source.git
revision: usage_record_enable_config
warn-unpinned: false
Comment on lines +2 to +7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to update before merge.