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

Releases/v0.12.latest #83

Merged
merged 10 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# dbt_stripe_source v0.12.1

## Feature Updates
- Declaration of passthrough variables for the `stg_stripe__card` model. This can, for example, be used to pull in non-standard columns from Stripe such as `description`, `iin` and `issuer`. See the [README](https://github.com/fivetran/dbt_stripe_source?tab=readme-ov-file#passing-through-additional-fields) for more details ([PR #81](https://github.com/fivetran/dbt_stripe_source/pull/81)).

```yaml
# dbt_project.yml
fivetran-avinash marked this conversation as resolved.
Show resolved Hide resolved

vars:
stripe_source:
card_pass_through_columns:
- name: "description"
- name: "iin"
- name: "issuer"
alias: "card_issuer" # optional: define an alias for the column
transform_sql: "cast(card_issuer as string)" # optional: apply transformation to column. must reference the alias if provided
```

## Under the Hood

Choose a reason for hiding this comment

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

@fivetran-jamie I think something is up with the triple quoting here that is causing the Under the Hood section to be quoted.

- Removed un-used columns from the `get_card_columns()` [macro](https://github.com/fivetran/dbt_stripe_source/blob/main/macros/get_card_columns.sql) and aliased the `metadata` field, which is parsed via the `stripe__card_metadata` [variable](https://github.com/fivetran/dbt_stripe_source?tab=readme-ov-file#pivoting-out-metadata-properties), but not included as a field in its entirety in `stg_stripe__card` by default ([PR #83](https://github.com/fivetran/dbt_stripe_source/pull/83)).
- This ensures users can utilize the new `card_pass_through_columns` variable to include these fields in `stg_stripe__card`.

## Contributors
- [@bramrodenburg](https://github.com/bramrodenburg) ([#81](https://github.com/fivetran/dbt_stripe_source/pull/81))

# dbt_stripe_source v0.12.0

[PR [#77](https://github.com/fivetran/dbt_stripe_source/pull/77)] includes the following updates:
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ vars:
stripe__subscription_metadata: ['the', 'list', 'of', 'property', 'fields'] # Note: this is case-SENSITIVE and must match the casing of the property as it appears in the JSON
```

#### 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:

```yml
# dbt_project.yml

vars:
stripe_source:
card_pass_through_columns:
- name: "description"
- name: "iin"
- name: "issuer"
alias: "card_issuer" # optional: define an alias for the column
transform_sql: "cast(card_issuer as string)" # optional: apply transformation to column. must reference the alias if provided
```

#### Change the build schema
By default, this package builds the stripe staging models within a schema titled (`<target_schema>` + `_stg_stripe`) in your destination. If this is not where you would like your stripe staging data to be written to, add the following configuration to your root `dbt_project.yml` file:

Expand All @@ -195,7 +211,7 @@ If an individual source table has a different name than the package expects, add
vars:
stripe_<default_source_table_name>_identifier: your_table_name
```

</details>

### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
Expand Down
6 changes: 4 additions & 2 deletions 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.12.0'
version: '0.12.1'
require-dbt-version: [">=1.3.0", "<2.0.0"]

models:
Expand Down Expand Up @@ -33,4 +33,6 @@ vars:
refund: "{{ source('stripe', 'refund') }}"
subscription_history: "{{ source('stripe', 'subscription_history') }}"
subscription: "{{ source('stripe', 'subscription') }}"
transfer: "{{ source('stripe', 'transfer') }}"
transfer: "{{ source('stripe', 'transfer') }}"

card_pass_through_columns: []
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.

12 changes: 11 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
config-version: 2

name: 'stripe_source_integration_tests'
version: '0.12.0'
version: '0.12.1'


profile: 'integration_tests'

vars:
stripe_schema: stripe_source_integrations_tests_6

stripe_source:
card_pass_through_columns:
Copy link

@fivetran-avinash fivetran-avinash Oct 2, 2024

Choose a reason for hiding this comment

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

@fivetran-jamie Should we remove these variables? I assume it was only for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Figured there's no harm in including them in integration tests moving forward 🤷

- name: "description"
- name: iin
- name: exp_year
alias: exp_year_alias
transform_sql: exp_year_alias * 2.0
- name: fingerprint
- name: metadata

stripe_account_identifier: "account_data"
stripe_group_identifier: "group_data"
stripe_balance_transaction_identifier: "balance_transaction_data"
Expand Down
19 changes: 4 additions & 15 deletions macros/get_card_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,23 @@
{"name": "address_city", "datatype": dbt.type_string()},
{"name": "address_country", "datatype": dbt.type_string()},
{"name": "address_line_1", "datatype": dbt.type_string()},
{"name": "address_line_1_check", "datatype": dbt.type_string()},
{"name": "address_line_2", "datatype": dbt.type_string()},
{"name": "address_state", "datatype": dbt.type_string()},
{"name": "address_zip", "datatype": dbt.type_string()},
{"name": "address_zip_check", "datatype": dbt.type_string()},
{"name": "brand", "datatype": dbt.type_string()},
{"name": "connected_account_id", "datatype": dbt.type_string()},
{"name": "country", "datatype": dbt.type_string()},
{"name": "created", "datatype": dbt.type_timestamp()},
{"name": "currency", "datatype": dbt.type_string()},
{"name": "customer_id", "datatype": dbt.type_string()},
{"name": "cvc_check", "datatype": dbt.type_string()},
{"name": "dynamic_last_4", "datatype": dbt.type_string()},
{"name": "exp_month", "datatype": dbt.type_int()},
{"name": "exp_year", "datatype": dbt.type_int()},
{"name": "fingerprint", "datatype": dbt.type_string()},
{"name": "funding", "datatype": dbt.type_string()},
{"name": "id", "datatype": dbt.type_string()},
{"name": "is_deleted", "datatype": "boolean"},
{"name": "last_4", "datatype": dbt.type_string()},
{"name": "metadata", "datatype": dbt.type_string()},
{"name": "metadata", "datatype": dbt.type_string(), "alias": "card_metadata"},
{"name": "name", "datatype": dbt.type_string()},
{"name": "network", "datatype": dbt.type_string()},
{"name": "recipient", "datatype": dbt.type_string()},
{"name": "tokenization_method", "datatype": dbt.type_string()},
{"name": "wallet_type", "datatype": dbt.type_string()},
{"name": "wallet_type", "datatype": dbt.type_string()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('card_pass_through_columns')) }}

{{ return(columns) }}

{% endmacro %}
4 changes: 3 additions & 1 deletion models/stg_stripe__card.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ final as (
source_relation

{% if var('stripe__card_metadata',[]) %}
, {{ fivetran_utils.pivot_json_extract(string = 'metadata', list_of_properties = var('stripe__card_metadata')) }}
, {{ fivetran_utils.pivot_json_extract(string = 'card_metadata', list_of_properties = var('stripe__card_metadata')) }}
{% endif %}

{{ fivetran_utils.fill_pass_through_columns('card_pass_through_columns') }}

from fields
)

Expand Down
Loading