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

add var for CALL + update way we disable source freshness #6

Merged
merged 28 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33742f3
Flag for call source
raphaelvarieras May 4, 2024
c2ac0d5
Flag for message
raphaelvarieras May 4, 2024
48e16c2
Fix comment referencing wrong variable name
raphaelvarieras May 4, 2024
91bd076
Update buildkite script
raphaelvarieras May 4, 2024
32c70c1
Fix case for loader name
raphaelvarieras May 4, 2024
048a74d
Document
raphaelvarieras May 4, 2024
e34f0c2
Document
raphaelvarieras May 4, 2024
79ce9db
Merge pull request #5 from raphaelvarieras/add-flag-for-call-models
fivetran-jamie May 6, 2024
85f8507
staging
fivetran-jamie May 6, 2024
df35848
revert
fivetran-jamie May 7, 2024
ef2f462
star
fivetran-jamie May 7, 2024
c19191c
switch vars
fivetran-jamie May 7, 2024
8c7ee3d
snowflake
fivetran-jamie May 7, 2024
a1f3ac1
more snowflake
fivetran-jamie May 7, 2024
394aba7
try passing snowflake macro without braces
fivetran-jamie May 7, 2024
765fd5a
try this
fivetran-jamie May 7, 2024
f6ce4d3
last try
fivetran-jamie May 7, 2024
b603737
revert dbt_utils.star change
fivetran-jamie May 7, 2024
a036941
docs
fivetran-jamie May 7, 2024
eb866af
docs
fivetran-jamie May 7, 2024
afb0356
try aliasing for snowflake
fivetran-jamie May 8, 2024
ab334d7
use alias
fivetran-jamie May 8, 2024
8a20b75
Update CHANGELOG.md
fivetran-jamie May 8, 2024
7c36487
joe and raphael feedback
fivetran-jamie May 8, 2024
bfd7b4a
update bk emoji
fivetran-jamie May 9, 2024
d289b30
add breaking change alarms
fivetran-jamie May 9, 2024
a55340d
add databricks creds
fivetran-jamie May 9, 2024
be98c86
try downgrading dbt-spark adapter
fivetran-jamie May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export CI_SNOWFLAKE_DBT_USER=$(gcloud secrets versions access latest --secret="C
export CI_SNOWFLAKE_DBT_WAREHOUSE=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_WAREHOUSE" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_HOST=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HOST" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_HTTP_PATH=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HTTP_PATH" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_TOKEN=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_TOKEN" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_TOKEN=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_TOKEN" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_CATALOG=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_CATALOG" --project="dbt-package-testing-363917")
3 changes: 2 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ steps:
commands: |
bash .buildkite/scripts/run_models.sh redshift

- label: ":bricks: Run Tests - Databricks"
- label: ":databricks: Run Tests - Databricks"
key: "run_dbt_databricks"
plugins:
- docker#v3.13.0:
Expand All @@ -69,5 +69,6 @@ steps:
- "CI_DATABRICKS_DBT_HOST"
- "CI_DATABRICKS_DBT_HTTP_PATH"
- "CI_DATABRICKS_DBT_TOKEN"
- "CI_DATABRICKS_DBT_CATALOG"
commands: |
bash .buildkite/scripts/run_models.sh databricks
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_messaging_service: false}' --target "$db" --full-refresh
dbt run --vars '{using_twilio_call: false, using_twilio_messaging_service: false}' --target "$db" --full-refresh
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
42 changes: 10 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,26 @@
**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
- [ ] 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:
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ We are so excited you decided to contribute to the Fivetran community dbt packag
**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)
- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# dbt_twilio_source v0.2.0

## 🚨 Breaking Changes 🚨
- Under the hood, we've updated the `_tmp` models to use the `dbt_utils.star` macro instead of a basic `select *` ([PR #6](https://github.com/fivetran/dbt_twilio_source/pull/6)).
- This means that you can no longer use `var(<table_name>)` to override the source tables we create staging models from. Instead, see the [README](https://github.com/fivetran/dbt_twilio_source?tab=readme-ov-file#change-the-source-table-references) for how to use our `_identifier` variables.
- Removed the deprecated `twilio_using_message` variable. This is a breaking change because you could previously use this variable to disable freshness tests on the `MESSAGE` source table. To continue to do so, leverage dbt [overrides](https://docs.getdbt.com/reference/resource-properties/overrides#configure-your-own-source-freshness-for-a-source-table-in-a-package) to set `message`'s freshness to `null` ([PR #6](https://github.com/fivetran/dbt_twilio_source/pull/6)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know why we're capitalizing MESSAGE here? The source table is message in the dbt_project.yml. Is it because the customer is using Snowflake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just capitalizing it to highlight it as a source table (as opposed to a package model or a column)


## Features
- Added the ability to disable models related to the `CALL` source table. Refer to the [README](https://github.com/fivetran/dbt_twilio_source?tab=readme-ov-file#step-4-enablingdisabling-models) for more details ([PR #5](https://github.com/fivetran/dbt_twilio_source/pull/5)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar question regarding CALL vs. call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just a stylistic choice - i tend to capitalize raw source tables in documentation to highlight that they're not package models or columns


## Under the Hood
- Adjusted the case of loader name from `fivetran` to `Fivetran` in the `src_twilio.yml` file ([PR #5](https://github.com/fivetran/dbt_twilio_source/pull/5)).
- Adjusted the way we dynamically disable source freshness tests for tables that may be missing to use dbt's native `config.enabled` [flag](https://docs.getdbt.com/reference/resource-configs/enabled) ([PR #6](https://github.com/fivetran/dbt_twilio_source/pull/6)).
- Updated the pull request [templates](/.github) ([PR #6](https://github.com/fivetran/dbt_twilio_source/pull/6)).
- Included auto-releaser GitHub Actions workflow to automate future releases ([PR #6](https://github.com/fivetran/dbt_twilio_source/pull/6)).

## Contributors
- [@raphaelvarieras](https://github.com/raphaelvarieras) ([PR #5](https://github.com/fivetran/dbt_twilio_source/pull/5))

# dbt_twilio_source v0.1.0

## Initial Release
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Include the following Twilio package version in your `packages.yml` file.
```yaml
packages:
- package: fivetran/twilio_source
version: [">=0.1.0", "<0.2.0"]
version: [">=0.2.0", "<0.3.0"]
```

## Step 3: Define database and schema variables
Expand All @@ -55,6 +55,7 @@ vars:
twilio_database: your_database_name
twilio_schema: your_schema_name
```

## Step 4: Enabling/Disabling Models

Your Twilio connector might not sync every table that this package expects, for example if you are not using the Twilio messaging service feature. If your syncs exclude certain tables, it is either because you do not use that functionality in Twilio or have actively excluded some tables from your syncs. In order to enable or disable the relevant tables in the package, you will need to add the following variable(s) to your `dbt_project.yml` file.
Expand All @@ -63,12 +64,13 @@ By default, all variables are assumed to be `true`.

```yml
vars:
using_twilio_call: False # Disable this if not using call
using_twilio_messaging_service: False # Disable this if not using messaging_service
```

## (Optional) Step 5: Additional configurations

<details><summary>Expand for details</summary>
<details open><summary>Expand/Collapse details</summary>
<br>

### Changing the Build Schema
Expand All @@ -80,8 +82,9 @@ models:
twilio_source:
+schema: my_new_schema_name # leave blank for just the target_schema
```

### Change the source table references
If an individual source table has a different name than what the package expects, add the table name as it appears in your destination to the respective variable:
If an individual source table has a different name than what the package expects (but is in the same schema and database as the other tables), add the table name as it appears in your destination to the respective variable:
> IMPORTANT: See this project's [`dbt_project.yml`](https://github.com/fivetran/dbt_twilio_source/blob/main/dbt_project.yml) variable declarations to see the expected names.

```yml
Expand Down Expand Up @@ -119,11 +122,10 @@ packages:
The Fivetran team maintaining this package _only_ maintains the latest version of the package. We highly recommend you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/twilio_source/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_twilio_source/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.

## Contributions
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions!
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions!

We highly encourage and welcome contributions to this package. Check out [this dbt Discourse article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) on the best workflow for contributing to a package!

# 🏪 Are there any resources available?
- If you have questions or want to reach out for help, please refer to the [GitHub Issue](https://github.com/fivetran/dbt_twilio_source/issues/new/choose) section to find the right avenue of support for you.
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).
- Have questions or want to be part of the community discourse? Create a post in the [Fivetran community](https://community.fivetran.com/t5/user-group-for-dbt/gh-p/dbt-user-group) and our team along with the community can join in on the discussion!
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: 'twilio_source'
version: '0.1.0'
version: '0.2.0'
config-version: 2

models:
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.

3 changes: 2 additions & 1 deletion integration_tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
target/
dbt_modules/
logs/
.DS_Store
.DS_Store
package-lock.yml
2 changes: 1 addition & 1 deletion integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ integration_tests:
schema: twilio_source_integration_tests_1
threads: 8
databricks:
catalog: null
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: twilio_source_integration_tests_1
Expand Down
12 changes: 6 additions & 6 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
config-version: 2
name: 'twilio_source_integration_tests'

version: '0.1.0'
version: '0.2.0'
profile: 'integration_tests'

vars:
Expand All @@ -13,9 +12,8 @@ vars:
twilio_messaging_service_identifier: "twilio_messaging_service_data"
twilio_outgoing_caller_id_identifier: "twilio_outgoing_caller_id_data"
twilio_usage_record_identifier: "twilio_usage_record_data"
call: "{{ fivetran_utils.snowflake_seed_data('twilio_call_data') }}"
message: "{{ fivetran_utils.snowflake_seed_data('twilio_message_data') }}"

twilio_call_identifier: "twilio_call_data"
twilio_message_identifier: "twilio_message_data"

dispatch:
- macro_namespace: dbt_utils
Expand All @@ -35,5 +33,7 @@ seeds:
+enabled: "{{ true if target.type != 'snowflake' else false }}"
twilio_message_data_snowflake:
+enabled: "{{ true if target.type == 'snowflake' else false }}"
+alias: twilio_message_data
twilio_call_data_snowflake:
+enabled: "{{ true if target.type == 'snowflake' else false }}"
+enabled: "{{ true if target.type == 'snowflake' else false }}"
+alias: twilio_call_data
2 changes: 1 addition & 1 deletion integration_tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dbt-bigquery>=1.3.0,<2.0.0
dbt-redshift>=1.3.0,<2.0.0
dbt-postgres>=1.3.0,<2.0.0
dbt-spark>=1.3.0,<2.0.0
dbt-spark[PyHive]>=1.3.0,<2.0.0
dbt-spark[PyHive]>=1.3.0,<1.8.0
dbt-databricks>=1.3.0,<2.0.0
12 changes: 5 additions & 7 deletions models/src_twilio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sources:
database: "{{ var('twilio_database', target.database)}}"
schema: "{{ var('twilio_schema', 'twilio')}}"

loader: fivetran
loader: Fivetran
loaded_at_field: _fivetran_synced

tables:
Expand Down Expand Up @@ -96,8 +96,8 @@ sources:
- name: call
identifier: "{{ var('twilio_call_identifier', 'call' )}}"
description: Each record represents a phone call that occurred or is scheduled to occur.
meta:
is_enabled: "{{ var('using_twilio_call', true) }}"
config:
enabled: "{{ var('using_twilio_call', true) }}"
freshness:
warn_after: {count: 72, period: hour}
error_after: {count: 168, period: hour}
Expand Down Expand Up @@ -283,8 +283,6 @@ sources:
- name: message
identifier: "{{ var('twilio_message_identifier', 'message' )}}"
description: Each record represents an individual outbound or inbound message.
meta:
is_enabled: "{{ var('using_twilio_message', true) }}"
freshness:
warn_after: {count: 72, period: hour}
error_after: {count: 168, period: hour}
Expand Down Expand Up @@ -346,8 +344,8 @@ sources:
- name: messaging_service
identifier: "{{ var('twilio_messaging_service_identifier', 'messaging_service' )}}"
description: Each record represents information about each messaging service. You can think of messaging services as a higher-level “bundling” of messaging functionality around a common set of senders, features, and configuration
meta:
is_enabled: "{{ var('using_twilio_messaging_service', true) }}"
config:
enabled: "{{ var('using_twilio_messaging_service', true) }}"
columns:
- name: _fivetran_synced
description: Timestamp of when fivetran synced a record.
Expand Down
3 changes: 3 additions & 0 deletions models/stg_twilio__call.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
--To disable this model, set the using_twilio_call variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_twilio_call', True)) }}

with base as (

select *
Expand Down
2 changes: 1 addition & 1 deletion models/stg_twilio__messaging_service.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--To disable this model, set the using_domain_names variable within your dbt_project.yml file to False.
--To disable this model, set the using_twilio_messaging_service variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_twilio_messaging_service', True)) }}

with base as (
Expand Down
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__account_history_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'account_history')) }}
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
from {{ var('account_history') }}
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__address_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'address')) }}
from {{ var('address') }}
5 changes: 4 additions & 1 deletion models/tmp/stg_twilio__call_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
select *
--To disable this model, set the using_twilio_call variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_twilio_call', True)) }}

select {{ dbt_utils.star(source('twilio', 'call')) }}
from {{ var('call') }}
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__incoming_phone_number_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'incoming_phone_number')) }}
from {{ var('incoming_phone_number') }}
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__message_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'message')) }}
from {{ var('message') }}
4 changes: 2 additions & 2 deletions models/tmp/stg_twilio__messaging_service_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--To disable this model, set the using_domain_names variable within your dbt_project.yml file to False.
--To disable this model, set the using_twilio_messaging_service variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_twilio_messaging_service', True)) }}

select *
select {{ dbt_utils.star(source('twilio', 'messaging_service')) }}
from {{ var('messaging_service') }}
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__outgoing_caller_id_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'outgoing_caller_id')) }}
from {{ var('outgoing_caller_id') }}
2 changes: 1 addition & 1 deletion models/tmp/stg_twilio__usage_record_tmp.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
select *
select {{ dbt_utils.star(source('twilio', 'usage_record')) }}
from {{ var('usage_record') }}