Skip to content

Commit

Permalink
feat: add non-standard columns to card model.
Browse files Browse the repository at this point in the history
  • Loading branch information
bramrodenburg committed Sep 10, 2024
1 parent ed464b6 commit 3b90664
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,18 @@ If an individual source table has a different name than the package expects, add
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
12 changes: 12 additions & 0 deletions macros/get_card_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
{"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 %}

{{ return(columns) }}

{% endmacro %}
9 changes: 9 additions & 0 deletions models/stg_stripe__card.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ 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 Down

0 comments on commit 3b90664

Please sign in to comment.