diff --git a/CHANGELOG.md b/CHANGELOG.md index 94659439..afb374f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/README.md b/README.md index 4c72f1a1..f4005c04 100644 --- a/README.md +++ b/README.md @@ -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 (`` + `_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: @@ -196,17 +211,6 @@ vars: stripe__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 -``` - ### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Coreā„¢ diff --git a/dbt_project.yml b/dbt_project.yml index e596b7f7..0d1fe5e3 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -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: @@ -33,4 +33,6 @@ vars: refund: "{{ source('stripe', 'refund') }}" subscription_history: "{{ source('stripe', 'subscription_history') }}" subscription: "{{ source('stripe', 'subscription') }}" - transfer: "{{ source('stripe', 'transfer') }}" \ No newline at end of file + transfer: "{{ source('stripe', 'transfer') }}" + + card_pass_through_columns: [] \ No newline at end of file diff --git a/macros/get_card_columns.sql b/macros/get_card_columns.sql index 41bbc465..01de23a9 100644 --- a/macros/get_card_columns.sql +++ b/macros/get_card_columns.sql @@ -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) }} diff --git a/models/stg_stripe__card.sql b/models/stg_stripe__card.sql index fe987c7d..54014389 100644 --- a/models/stg_stripe__card.sql +++ b/models/stg_stripe__card.sql @@ -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 @@ -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 )