將 Shopify 資料載入 BigQuery
您可以使用 BigQuery 資料移轉服務的 Shopify 連接器,將資料從 Shopify 載入 BigQuery。您可以使用 BigQuery 資料移轉服務,安排週期性移轉工作,將 Shopify 的最新資料新增至 BigQuery。
Shopify 連接器支援從下列資源移轉 GraphQL 資源的資料,例如 Collections 和 Orders:
- 訂閱制帳戶
- 合作夥伴帳戶
限制
Shopify 資料移轉作業有下列限制:
- 如要在資料移轉作業中加入
GiftCards物件,與這項資料移轉作業相關聯的帳戶必須訂閱 ShopifyPlus。 - 如要在資料移轉作業中加入下列應用程式訂閱資料物件,Shopify 商店安裝的應用程式必須是銷售通路應用程式。
AppSubscriptionLineItemsAppSubscriptionsProductResourceFeedbacks
- 如要納入下列需要折扣函式的 Shopify 資料物件,您必須使用 Shopify CLI 建立 Shopify 應用程式。
DiscountsCodeAppDiscountsCodeBasic
事前準備
以下各節說明建立 Shopify 資料移轉作業前,必須完成的前置作業。
Shopify 必要條件
- 你必須擁有 Shopify 帳戶和 Shopify 商店。
- Shopify 商店必須有自訂 Shopify 應用程式。詳情請參閱「自訂應用程式」。
- 您必須具備所需範圍的存取權,才能將 Shopify 資料物件移轉至 BigQuery。如需各物件的必要範圍清單,請參閱「支援的物件和必要範圍」。
BigQuery 事前準備
- 確認您已完成啟用 BigQuery 資料移轉服務的所有必要動作。
- 請建立 BigQuery 資料集來儲存您的資料。
必要的 BigQuery 角色
如要取得建立 BigQuery 資料移轉服務資料移轉作業所需的權限,請要求管理員授予您專案的 BigQuery 管理員 (roles/bigquery.admin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這個預先定義的角色具備建立 BigQuery 資料移轉服務資料移轉作業所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:
所需權限
您必須具備下列權限,才能建立 BigQuery 資料移轉服務資料移轉作業:
-
BigQuery 資料移轉服務權限:
-
bigquery.transfers.update -
bigquery.transfers.get
-
-
BigQuery 權限:
-
bigquery.datasets.get -
bigquery.datasets.getIamPolicy -
bigquery.datasets.update -
bigquery.datasets.setIamPolicy -
bigquery.jobs.create
-
詳情請參閱「授予 bigquery.admin 存取權」。
如要設定 Pub/Sub 的移轉作業執行通知,請確認您具備 pubsub.topics.setIamPolicy Identity and Access Management (IAM) 權限。如果只設定電子郵件通知,則不需要 Pub/Sub 權限。詳情請參閱「BigQuery 資料移轉服務執行通知」。
設定 Shopify 資料移轉作業
使用下列任一選項設定移轉設定,將 Shopify 資料新增至 BigQuery:
控制台
前往 Cloud de Confiance 控制台的「Data transfers」(資料移轉) 頁面。
按一下「 建立移轉作業」。
在「Source type」(來源類型) 部分,「Source」(來源) 請選取「Shopify」。
在「Data source details」(資料來源詳細資料) 部分執行下列操作:
- 在「Shop name」(商店名稱) 部分,輸入 Shopify 商店名稱。舉例來說,如果商家帳戶 ID 是
storename.myshopify.com,則商店名稱為storename。 - 在「Client ID」(用戶端 ID) 和「Client Secret」(用戶端密鑰) 中,輸入 Shopify 應用程式的用戶端 ID 和密鑰。詳情請參閱「關於用戶端密鑰」。
- 在「Shopify objects to transfer」(要移轉的 Shopify 物件) 部分,點選「Browse」(瀏覽):
- 選取要轉移至 BigQuery 目的地資料集的所有物件。您也可以在這個欄位手動輸入要移轉資料的物件。
- 在「Shop name」(商店名稱) 部分,輸入 Shopify 商店名稱。舉例來說,如果商家帳戶 ID 是
在「Destination settings」(目的地設定) 部分,「Dataset」(資料集) 請選取您為了儲存資料而建立的資料集。
在「Transfer config name」(轉移設定名稱) 部分,「Display name」(顯示名稱) 請輸入資料移轉作業名稱。
在「Schedule options」(排程選項) 專區:
- 在「Repeat frequency」(重複執行頻率) 清單中,選取選項,指定這項資料移轉作業的執行頻率。如要指定自訂重複頻率,請選取「Custom」(自訂)。如果選取「On-demand」(隨選),這項移轉作業會在您手動觸發後執行。
- 視情況選取「Start now」(立即開始) 或「Start at set time」(在所設時間開始執行),並提供開始日期和執行時間。
選用:在「Notification options」(通知選項) 專區,執行下列操作:
- 如要啟用電子郵件通知,請點選「Email notification」(電子郵件通知) 切換按鈕。啟用這個選項之後,若移轉失敗,移轉作業管理員就會收到電子郵件通知。
- 如要針對這項移轉作業啟用 Pub/Sub 移轉作業執行通知,請點選「Pub/Sub notifications」(Pub/Sub 通知) 切換按鈕。您可以選取主題名稱,也可以點選「Create a topic」(建立主題) 來建立主題。
按一下 [儲存]。
bq
輸入 bq mk 指令,並提供轉移作業建立旗標 --transfer_config:
bq mk --transfer_config --project_id=PROJECT_ID --data_source=DATA_SOURCE --display_name=NAME --target_dataset=DATASET --params='PARAMETERS'
其中:
- PROJECT_ID (選用): Cloud de Confiance by S3NS 專案 ID。如未提供
--project_id來指定特定專案,系統會使用預設專案。 - DATA_SOURCE:資料來源 -
shopify。 - NAME:資料移轉設定的顯示名稱。移轉作業名稱可以是任意值,日後需要修改移轉作業時,能夠據此識別即可。
- DATASET:移轉設定的目標資料集。
PARAMETERS:所建立移轉設定的參數,採用 JSON 格式。例如:
--params='{"param":"param_value"}'。以下是 Shopify 資料移轉的參數:assets:要移轉至 BigQuery 的 Shopify 物件路徑。connector.shopName:Shopify 商店名稱。舉例來說,如果商家帳戶 ID 是storename.myshopify.com,則商店名稱為storename。connector.authentication.accessToken:Shopify Admin API 存取權杖。
下列指令會在預設專案中建立遞增 Shopify 資料移轉作業。
bq mk --transfer_config --target_dataset=mydataset --data_source=shopify --display_name='My Transfer' --params='{"assets": ["Orders"] "connector.shopName": "storename", "connector.authentication.accessToken":"sk_test_123456789"}'
如要在排程時間以外手動執行資料移轉作業,可以啟動補充執行作業。
支援的物件和必要範圍
下表列出可移轉至 BigQuery 的 Shopify 資料物件,以及各物件所需的範圍。
| 資料物件 | 必要範圍 | |
|---|---|---|
| AppFeedbacks | 不需指定範圍 | |
| AppSubscriptionLineItems | 不需指定範圍 | |
| AppSubscriptions | 不需指定範圍 | |
| 目錄 | read_products或read_product_listings |
|
read_publications |
||
| 珍藏內容 | read_products |
|
read_publications |
||
| 公司 | read_customers或read_companies |
|
| CompanyContactRoleAssignments | read_customers或read_companies |
|
| CompanyContacts | read_customers或read_companies |
|
| CompanyLocations | read_customers或read_companies |
|
| 客戶 | read_customers |
|
write_customers |
||
read_customer_merge |
||
read_locations或read_inventory |
||
read_markets |
||
read_orders |
||
| DeliveryProfiles | read_products |
|
read_shipping |
||
| DiscountsAutomaticApp | read_discounts |
|
| DiscountsAutomaticBasic | read_discounts |
|
| DiscountsAutomaticBxgy | read_discounts |
|
| DiscountsCodeApp | read_discounts |
|
| DiscountsCodeBasic | read_discounts |
|
| DiscountsCodeBxgy | read_discounts |
|
| DraftOrders | read_customers |
|
read_draft_orders |
||
read_orders |
||
read_payment_terms |
||
| 檔案 | read_files |
|
| FulfillmentEvents | read_orders |
|
| FulfillmentOrders | read_locations |
|
read_orders |
||
read_assigned_fulfillment_orders、read_merchant_managed_fulfillment_orders 或 read_third_party_fulfillment_orders |
||
| Fulfillment | read_fulfillments或read_products |
|
read_locations |
||
read_orders |
||
| FulfillmentServices | read_locations或read_inventory |
|
read_fulfillments、read_products、read_custom_fulfillment_services 或 assigned_fulfillment_orders |
||
| FulfillmentTrackingInfo | read_fulfillments或read_products |
|
read_locations |
||
read_orders |
||
| GiftCards | read_gift_cards |
|
read_orders |
||
read_customers |
||
| InventoryItems | read_inventory |
|
read_products |
||
| 位置 | read_locations |
|
read_fulfillments |
||
| Metafields_Article | read_content |
|
| Metafields_Blog | read_content |
|
| Metafields_Collection | read_products |
|
read_publications |
||
| Metafields_Customer | read_customers |
|
write_customers |
||
read_customer_merge |
||
read_locations或read_inventory |
||
read_markets |
||
read_orders |
||
| Metafields_Draft_Order | read_customers |
|
read_draft_orders |
||
read_orders |
||
read_payment_terms |
||
| Metafields_Order | read_customers |
|
read_inventory |
||
read_locations |
||
read_orders |
||
read_payment_terms |
||
| Metafields_Page | read_content |
|
| Metafields_Product | read_products |
|
read_product_listings |
||
read_publications |
||
| Metafields_Selling_Plan | read_products |
|
| Metafields_Shop | 不需指定範圍 | |
| Metafields_Variant | read_products |
|
read_shipping |
||
| OrderLineItems | read_orders |
|
read_products |
||
| OrderRiskAssessments | read_orders |
|
| 訂單 | read_customers |
|
read_inventory |
||
read_locations |
||
read_orders |
||
read_payment_terms |
||
read_draft_orders |
||
read_products或read_fulfillments |
||
| OrderTransactions | read_orders |
|
read_products |
||
| PriceLists | read_products |
|
| ProductMediaImages | read_products |
|
| ProductOptions | read_products |
|
| ProductOptionValues | read_products |
|
| ProductResourceFeedbacks | read_resource_feedbacks |
|
read_products |
||
| 產品 | read_products |
|
read_product_listings |
||
read_publications |
||
| ProductVariants | read_products |
|
read_shipping |
||
| 出版品 | read_products |
|
read_publications |
||
| 退款 | read_products |
|
read_orders |
||
read_returns |
||
| 退貨 | read_orders |
|
read_returns |
||
| ScriptTags | read_script_tags |
|
| 區隔 | read_customers |
|
| SellingPlanGroups | read_products |
|
| StorefrontAccessTokens | 不需指定範圍 | |
| UrlRedirects | read_online_store_navigation |
資料類型對應
下表將 Shopify 資料類型對應至相應的 BigQuery 資料類型:
| Shopify 資料類型 | BigQuery 資料類型 |
|---|---|
String |
STRING |
Int |
INT64 |
Decimal |
NUMERIC |
Double |
FLOAT64 |
Long |
BIGNUMERIC |
Bool |
BOOL |
Datetime |
TIMESTAMP |
定價
這項功能處於預先發布版階段,將 Shopify 資料移轉至 BigQuery 不會產生費用。
排解轉移設定問題
如果無法順利設定資料移轉作業,請參閱「Shopify 移轉問題」。
後續步驟
- 如需 BigQuery 資料移轉服務的總覽,請參閱「什麼是 BigQuery 資料移轉服務」。
- 如要瞭解如何使用移轉作業,包括取得移轉設定資訊、列出移轉設定,以及查看移轉作業的執行記錄,請參閱「管理移轉作業」。