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

Feature/shopify api updates #70

Merged
merged 11 commits into from
Jun 28, 2023
23 changes: 19 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# dbt_shopify_source v0.UPDATE.UPDATE
# dbt_shopify_source v0.9.0
## Breaking Changes
- In [June 2023](https://fivetran.com/docs/applications/shopify/changelog#june2023) the Shopify connector received an update which upgraded the connector to be compatible with the new [2023-04 Shopify API](https://shopify.dev/docs/api). As a result, the following fields have been removed as they were deprecated in the API upgrade: ([PR #70](https://github.com/fivetran/dbt_shopify_source/pull/70))

| **model** | **field removed** |
|-------|--------------|
| [stg_shopify__customer](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__customer) | `lifetime_duration` |
| [stg_shopify__order_line](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__order_line) | `fulfillment_service` |
| [stg_shopify__order_line](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__order_line) | `destination_location_*` fields |
| [stg_shopify__order_line](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__order_line) | `origin_location_*` fields |
| [stg_shopify__order](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__order) | `total_price_usd` |
| [stg_shopify__order](https://fivetran.github.io/dbt_shopify/#!/model/model.shopify_source.stg_shopify__order) | `processing_method` |

## Under the Hood:
## Under the Hood
- Removed `databricks` from the shopify_database configuration in the src_shopify.yml to allow Databricks Unity catalog users to define a unity Catalog as a database. ([PR #70](https://github.com/fivetran/dbt_shopify_source/pull/70))
- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job. ([PR #65](https://github.com/fivetran/dbt_shopify_source/pull/65))
- Updated the pull request templates. ([PR #65](https://github.com/fivetran/dbt_shopify_source/pull/65))

- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job.
- Updated the pull request [templates](/.github).
## Documentation Updates
- The `shopify_using_shop_metafields` variable was added to the Adding Metafields of the README. It was erroneously omitted in a previous release. ([PR #70](https://github.com/fivetran/dbt_shopify_source/pull/70))
- Documentation provided in the README for how to connect sources when leveraging the union schema/database feature. ([PR #70](https://github.com/fivetran/dbt_shopify_source/pull/70))

# dbt_shopify_source v0.8.2

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If you are **not** using the [Shopify transformation package](https://github.co
```yml
packages:
- package: fivetran/shopify_source
version: [">=0.8.0", "<0.9.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.9.0", "<0.10.0"] # we recommend using ranges to capture non-breaking changes automatically
```

## Step 3: Define database and schema variables
Expand All @@ -68,6 +68,10 @@ vars:
shopify_union_databases: ['shopify_usa','shopify_canada'] # use this if the data is in different databases/projects but uses the same schema name
```

Please be aware that the native source.yml connection set up in the package will not function when the union schema/database feature is utilized. Although the data will be correctly combined, you will not observe the sources linked to the package models in the Directed Acyclic Graph (DAG). This happens because the package includes only one defined source.yml.

To connect your multiple schema/database sources to the package models, follow the steps outlined in the [Union Data Defined Sources Configuration](https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source) section of the Fivetran Utils documentation for the union_data macro. This will ensure a proper configuration and correct visualization of connections in the DAG.

## Step 4: Enable `fulfillment_event` data

The package takes into consideration that not every Shopify connector may have `fulfillment_event` data enabled. However, this table does hold valuable information that is leveraged in the `shopify__daily_shop` model in the transformation package. `fulfillment_event` data is **disabled by default**.
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'shopify_source'
version: '0.8.2'
version: '0.9.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'shopify_source_integration_tests'
version: '0.8.2'
version: '0.9.0'
profile: 'integration_tests'
config-version: 2

Expand Down
1 change: 0 additions & 1 deletion macros/get_customer_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
{"name": "note", "datatype": dbt.type_string()},
{"name": "accepts_marketing_updated_at", "datatype": dbt.type_timestamp()},
{"name": "marketing_opt_in_level", "datatype": dbt.type_string()},
{"name": "lifetime_duration", "datatype": dbt.type_string()},
{"name": "currency", "datatype": dbt.type_string()}
] %}

Expand Down
19 changes: 1 addition & 18 deletions macros/get_order_line_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt.type_timestamp()},
{"name": "fulfillable_quantity", "datatype": dbt.type_numeric()},
{"name": "fulfillment_service", "datatype": dbt.type_string()},
{"name": "fulfillment_status", "datatype": dbt.type_string()},
{"name": "gift_card", "datatype": "boolean"},
{"name": "grams", "datatype": dbt.type_numeric()},
Expand All @@ -28,23 +27,7 @@
{"name": "variant_title", "datatype": dbt.type_string()},
{"name": "variant_inventory_management", "datatype": dbt.type_string()},
{"name": "vendor", "datatype": dbt.type_string()},
{"name": "properties", "datatype": dbt.type_string()},
{"name": "destination_location_address_1", "datatype": dbt.type_string()},
{"name": "destination_location_address_2", "datatype": dbt.type_string()},
{"name": "destination_location_city", "datatype": dbt.type_string()},
{"name": "destination_location_country_code", "datatype": dbt.type_string()},
{"name": "destination_location_id", "datatype": dbt.type_int()},
{"name": "destination_location_name", "datatype": dbt.type_string()},
{"name": "destination_location_province_code", "datatype": dbt.type_string()},
{"name": "destination_location_zip", "datatype": dbt.type_string()},
{"name": "origin_location_address_1", "datatype": dbt.type_string()},
{"name": "origin_location_address_2", "datatype": dbt.type_string()},
{"name": "origin_location_city", "datatype": dbt.type_string()},
{"name": "origin_location_country_code", "datatype": dbt.type_string()},
{"name": "origin_location_id", "datatype": dbt.type_int()},
{"name": "origin_location_name", "datatype": dbt.type_string()},
{"name": "origin_location_province_code", "datatype": dbt.type_string()},
{"name": "origin_location_zip", "datatype": dbt.type_string()}
{"name": "properties", "datatype": dbt.type_string()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('order_line_pass_through_columns')) }}
Expand Down
52 changes: 5 additions & 47 deletions models/src_shopify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
sources:
- name: shopify # This source will only be used if you are using a single Shopify source connector. If multiple sources are being unioned, their tables will be directly referenced via adatper.get_relation
schema: "{{ var('shopify_schema', 'shopify') }}"
database: "{% if target.type not in ('spark', 'databricks') %}{{ var('shopify_database', target.database) }}{% endif %}"
database: "{% if target.type not in ('spark') %}{{ var('shopify_database', target.database) }}{% endif %}"
tables:
- name: order
description: Each record represents an order in Shopify.
Expand Down Expand Up @@ -87,8 +87,6 @@ sources:
description: The order 's position in the shop's count of orders starting at 1001. Order numbers are sequential and start at 1001.
- name: processed_at
description: The date and time when an order was processed. This value is the date that appears on your orders and that's used in the analytic reports.
- name: processing_method
description: How the payment was processed.
- name: referring_site
description: The website where the customer clicked a link to the shop.
- name: shipping_address_address_1
Expand Down Expand Up @@ -177,12 +175,8 @@ sources:
description: The total of all line item prices in shop and presentment currencies.
- name: total_price_set
description: The total price of the order in shop and presentment currencies.
- name: total_price_usd
description: The sum of all line item prices, discounts, shipping, taxes, and tips in USD. Must be positive.
- name: is_confirmed
description: Whether the order is confirmed.
- name: current_total_price
description: The current total price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds.
- name: source_identifier
description: The ID of the order placed on the originating platform. This value doesn't correspond to the Shopify ID that's generated from a completed draft.

Expand Down Expand Up @@ -230,8 +224,6 @@ sources:
description: Deprecated. The package will coalesce with `email_marketing_consent_consent_updated_at`.
- name: marketing_opt_in_level
description: Deprecated. The package will coalesce with `email_marketing_consent_opt_in_level`.
- name: lifetime_duration
description: The amount of time since the customer was first added to the store.
- name: _fivetran_deleted
description: "{{ doc('_fivetran_deleted') }}"
- name: note
Expand All @@ -247,8 +239,6 @@ sources:
description: "{{ doc('_fivetran_synced') }}"
- name: fulfillable_quantity
description: "The amount available to fulfill, calculated as follows: quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity - open_fulfilled_quantity"
- name: fulfillment_service
description: The service provider that's fulfilling the item.
- name: fulfillment_status
description: How far along an order is in terms line items fulfilled.
- name: gift_card
Expand Down Expand Up @@ -284,13 +274,13 @@ sources:
- name: index
description: Index of the order line.
- name: pre_tax_price
description: The pre tax preice of the line item in shop currency.
description: The pre tax price of the line item in shop currency.
- name: pre_tax_price_set
description: he pre tax preice of the line item in shop currency and presentment currency.
description: he pre tax price of the line item in shop currency and presentment currency.
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
- name: price_set
description: The price of the line item in shop and presentment currencies.
- name: tax_code
descripton: Tax code applied to the line item. As multiple taxes can apply to a line item, we recommend referring to `stg_shopify__tax_line`.
description: Tax code applied to the line item. As multiple taxes can apply to a line item, we recommend referring to `stg_shopify__tax_line`.
- name: total_discount_set
description: The total amount allocated to the line item in the presentment currency.
- name: variant_title
Expand All @@ -299,40 +289,8 @@ sources:
description: The fulfillment service that tracks the number of items in stock for the product variant.
- name: properties
description: Line item properties.
- name: destination_location_address_1
description: The street address of the assigned location.
- name: destination_location_address_2
description: An optional additional field for the street address of the assigned location.
- name: destination_location_city
description: City of the destination where the items should be sent.
- name: destination_location_country_code
description: Two-letter country code (ISO 3166-1 format) of the destination where the items should be sent.
- name: destination_location_id
description: ID of the destination where the items should be sent.
- name: destination_location_name
description: Name of the destination where the items should be sent.
- name: destination_location_province_code
description: Two-letter province code of the destination where the items should be sent.
- name: destination_location_zip
description: Zip code of the destination where the items should be sent.
- name: origin_location_address_1
description: The street address of the item's supplier.
- name: origin_location_address_2
description: The suite number of the item's supplier.
- name: origin_location_city
description: The city of the item's supplier.
- name: origin_location_country_code
description: The two-letter code (ISO 3166-1 format) for the country of the item's supplier.
- name: origin_location_id
description: The location ID of the line item’s fulfillment origin. Used by Shopify to calculate applicable taxes. This is not the ID of the location where the order was placed. You can use the FulfillmentOrder resource to determine the location an item will be sourced from.
- name: origin_location_name
description: The name of the item's supplier.
- name: origin_location_province_code
description: The two-letter abbreviation for the region of the item's supplier.
- name: origin_location_zip
description: The zip of the item's supplier.
- name: tax_code
descripton: Tax code applied to the line item. As multiple taxes can apply to a line item, we recommend referring to `stg_shopify__tax_line`.
description: Tax code applied to the line item. As multiple taxes can apply to a line item, we recommend referring to `stg_shopify__tax_line`.

- name: order_line_refund
identifier: "{{ var('shopify_order_line_refund_identifier', 'order_line_refund') }}"
Expand Down
44 changes: 1 addition & 43 deletions models/stg_shopify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ models:
description: The date and time when the customer information was last updated.
- name: is_verified_email
description: Whether the customer has verified their email address.
- name: lifetime_duration
description: The amount of time since the customer was first added to the store.
- name: currency
description: The three-letter code (ISO 4217 format) for the currency that the customer used when they paid for their last order. Defaults to the shop currency. Returns the shop currency for test orders.
- name: source_relation
Expand Down Expand Up @@ -99,8 +97,6 @@ models:
description: "{{ doc('_fivetran_synced') }}"
- name: fulfillable_quantity
description: "The amount available to fulfill, calculated as follows: quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity - open_fulfilled_quantity"
- name: fulfillment_service
description: The service provider that's fulfilling the item.
- name: fulfillment_status
description: How far along an order is in terms line items fulfilled.
- name: is_gift_card
Expand Down Expand Up @@ -153,38 +149,6 @@ models:
description: The fulfillment service that tracks the number of items in stock for the product variant.
- name: properties
description: Line item properties.
- name: destination_location_address_1
description: The street address of the assigned location.
- name: destination_location_address_2
description: An optional additional field for the street address of the assigned location.
- name: destination_location_city
description: City of the destination where the items should be sent.
- name: destination_location_country_code
description: Two-letter country code (ISO 3166-1 format) of the destination where the items should be sent.
- name: destination_location_id
description: ID of the destination where the items should be sent.
- name: destination_location_name
description: Name of the destination where the items should be sent.
- name: destination_location_province_code
description: Two-letter province code of the destination where the items should be sent.
- name: destination_location_zip
description: Zip code of the destination where the items should be sent.
- name: origin_location_address_1
description: The street address of the item's supplier.
- name: origin_location_address_2
description: The suite number of the item's supplier.
- name: origin_location_city
description: The city of the item's supplier.
- name: origin_location_country_code
description: The two-letter code (ISO 3166-1 format) for the country of the item's supplier.
- name: origin_location_id
description: The location ID of the line item’s fulfillment origin. Used by Shopify to calculate applicable taxes. This is not the ID of the location where the order was placed. You can use the FulfillmentOrder resource to determine the location an item will be sourced from.
- name: origin_location_name
description: The name of the item's supplier.
- name: origin_location_province_code
description: The two-letter abbreviation for the region of the item's supplier.
- name: origin_location_zip
description: The zip of the item's supplier.

- name: stg_shopify__order
description: Each record represents an order in Shopify.
Expand Down Expand Up @@ -272,8 +236,6 @@ models:
description: The order 's position in the shop's count of orders starting at 1001. Order numbers are sequential and start at 1001.
- name: processed_timestamp
description: The date and time when an order was processed. This value is the date that appears on your orders and that's used in the analytic reports.
- name: processing_method
description: How the payment was processed.
- name: referring_site
description: The website where the customer clicked a link to the shop.
- name: shipping_address_address_1
Expand Down Expand Up @@ -356,13 +318,9 @@ models:
description: The total of all line item prices in shop and presentment currencies.
- name: total_price_set
description: The total price of the order in shop and presentment currencies.
- name: total_price_usd
description: The sum of all line item prices, discounts, shipping, taxes, and tips in USD. Must be positive.
- name: is_confirmed
description: Whether the order is confirmed.
- name: current_total_price
description: The current total price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds.
- name: source_identifier
- name: source_relation
description: The ID of the order placed on the originating platform. This value doesn't correspond to the Shopify ID that's generated from a completed draft.

- name: stg_shopify__product
Expand Down
1 change: 0 additions & 1 deletion models/stg_shopify__customer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ final as (
total_spent,
verified_email as is_verified_email,
note,
lifetime_duration,
currency,
case
when email_marketing_consent_state is null then
Expand Down
2 changes: 0 additions & 2 deletions models/stg_shopify__order.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ final as (
total_line_items_price_set,
total_price,
total_price_set,
total_price_usd,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just make sure to remove these from the corresponding get column macros as well!

Copy link
Contributor

Choose a reason for hiding this comment

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

And processing method too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I missed removing these fields. Just updated.

total_tax_set,
total_tax,
source_name,
Expand All @@ -63,7 +62,6 @@ final as (
lower(email) as email,
financial_status,
fulfillment_status,
processing_method,
referring_site,
billing_address_address_1,
billing_address_address_2,
Expand Down
Loading