Skip to content

Commit

Permalink
implement feedback from issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bramrodenburg committed Sep 13, 2024
1 parent 3b90664 commit f2d3ac7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# dbt_stripe_source v0.12.1
[PR [#81]](https://github.com/fivetran/dbt_stripe_source/pull/81) includes the following updates:

## 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`.
```yml
# dbt_project.yml

vars:
stripe_source:
card_pass_through_columns:
- name: "description"
```
# dbt_stripe_source v0.12.0
[PR [#77](https://github.com/fivetran/dbt_stripe_source/pull/77)] includes the following updates:
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ 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
```

#### 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 @@ -196,17 +211,6 @@ vars:
stripe_<default_source_table_name>_identifier: your_table_name
```

#### Enable columns that are not available in standard Stripe API requests
The columns `description`, `iin` and `issuer` are not available by default in the card table ([see Fivetran docs](https://fivetran.com/docs/connectors/applications/stripe#schemanotes)).
To add these columns to the `stg_stripe__card` table, set the corresponding below variables to `true`.

```yml
vars:
stripe__card_using_description: true
stripe__card_using_iin: true
stripe__card_using_issuer: true
```

</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: []
12 changes: 1 addition & 11 deletions macros/get_card_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,7 @@
{"name": "wallet_type", "datatype": dbt.type_string()},
] %}

{%- if var('stripe__card_using_description', false) %}
{{ columns.append({"name": "description", "datatype": dbt.type_string()}) }}
{%- endif %}

{%- if var('stripe__card_using_iin', false) %}
{{ columns.append({"name": "iin", "datatype": dbt.type_string()}) }}
{%- endif %}

{%- if var('stripe__card_using_issuer', false) %}
{{ columns.append({"name": "issuer", "datatype": dbt.type_string()}) }}
{%- endif %}
{{ fivetran_utils.add_pass_through_columns(columns, var('card_pass_through_columns')) }}

{{ return(columns) }}

Expand Down
11 changes: 2 additions & 9 deletions models/stg_stripe__card.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ final as (
cast(created as {{ dbt.type_timestamp() }}) as created_at,
customer_id,
name as card_name,
{%- if var('stripe__card_using_description', false) %}
description,
{%- endif %}
{%- if var('stripe__card_using_iin', false) %}
iin,
{%- endif %}
{%- if var('stripe__card_using_issuer', false) %}
issuer,
{%- endif %}
recipient,
funding,
source_relation
Expand All @@ -57,6 +48,8 @@ final as (
, {{ fivetran_utils.pivot_json_extract(string = 'metadata', list_of_properties = var('stripe__card_metadata')) }}
{% endif %}

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

from fields
)

Expand Down

0 comments on commit f2d3ac7

Please sign in to comment.