Shopifyからデータを取り込む
ベータ版
This feature is in Beta.To use it, a ワークスペース admin must turn on Lakeflow Connect for Shopify from the Previews page.See Manage Databricks previews.
このページでは、Lakeflow Connect を使用してマネージド Shopify インジェスト パイプラインを作成する方法について説明します。
要件
-
取り込みパイプラインを作成するには、まず次の要件を満たす必要があります。
-
ワークスペースでUnity Catalogが有効になっている必要があります。
-
Serverless コンピュートをワークスペースで有効にする必要があります。Serverless コンピュートの要件を参照してください。
-
新しい接続を作成するには、メタストアに対する
CREATE CONNECTION特権が必要です。Unity Catalog での特権の管理を参照してください。コネクタが UI ベースのパイプライン オーサリングをサポートしている場合、管理者はこのページのステップを完了することで、接続とパイプラインを同時に作成できます。 ただし、パイプラインを作成するユーザーが API ベースのパイプライン オーサリングを使用している場合、または管理者以外のユーザーである場合、管理者はまずカタログ エクスプローラーで接続を作成する必要があります。 「管理対象取り込みソースへの接続」を参照してください。
-
既存の接続を使用するには、接続オブジェクトに対する
USE CONNECTION権限またはALL PRIVILEGES権限が必要です。 -
ターゲットカタログに対する
USE CATALOG権限が必要です。 -
既存のスキーマに対する
USE SCHEMAおよびCREATE TABLE権限、またはターゲットカタログに対するCREATE SCHEMA権限が必要です。
-
-
Shopify から取り込むには、まず Databricks から認証を構成し、接続を作成します。Shopify への認証の構成およびShopify 接続の作成を参照してください。
コネクター オプション
パイプラインスコープのオプションを source_configurations で設定します。使用方法については、Examplesを参照してください。
オプション | スコープ | 必須 | 適用対象 | 説明 |
|---|---|---|---|---|
| パイプライン | No | すべてのインクリメンタルテーブル | データを |
取り込みパイプラインを作成
サポートされているソース テーブルの一覧については、サポートされているソース テーブルを参照してください。
- Databricks UI
- Declarative Automation Bundles
- Databricks notebook
- Databricksワークスペースのサイドバーで、 データ取り込み をクリックします。
- データの追加 ページの Databricks コネクタ で、 Shopify をクリックします。
- On the Connection page of the ingestion wizard, select the connection that stores your Shopify credentials.If you have the
CREATE CONNECTIONprivilege on the metastore, clickCreate connection to create a connection with the credentials from Configure authentication to Shopify.
- 次へ をクリックします。
- インジェスト設定 ページで、パイプラインの名前を入力します。
- イベント Logs を書き込むカタログとスキーマを選択します。カタログに対する
USE CATALOG権限およびCREATE SCHEMA権限がある場合は、ドロップダウン メニューで[スキーマの作成] をクリックしてスキーマを作成します。
- パイプラインの作成および続行 をクリックします。
- On the Source page, select the tables to ingest.
- 保存して続行 をクリックします。
- 宛先 ページで、データを読み込むカタログとスキーマを選択します。カタログに対する
USE CATALOG権限とCREATE SCHEMA権限がある場合は、ドロップダウン メニューのCreate schema をクリックしてスキーマを作成します。
- 保存して続行 をクリックします。
- (オプション) スケジュールと通知 ページで、
スケジュールの作成 をクリックします。宛先テーブルを更新する頻度を設定します。
- (オプション)
通知の追加 をクリックして、パイプライン操作の成功または失敗に関するEメール通知を設定し、 保存してパイプラインを実行 をクリックします。
宣言型オートメーションバンドルを使用して、Shopify パイプラインをコードとして管理します。バンドルには、ジョブとタスクの YAML 定義を含めることができ、Databricks CLI を使用して管理され、異なるターゲット ワークスペース(開発、ステージング、本番運用など)で共有および実行できます。詳細については、「宣言型オートメーションバンドルとは?」をご覧ください。
-
Databricks CLIを使用してバンドルを作成します。
Bashdatabricks bundle init -
2 つの新しいリソース ファイルをバンドルに追加します。
- パイプライン定義ファイル(例:
resources/shopify_pipeline.yml)。「pipeline.ingestion_definition」を参照してください。および例。 - データ取り込みの頻度を制御するジョブ定義ファイル(例:
resources/shopify_job.yml)。
- パイプライン定義ファイル(例:
-
Databricks CLIを使用してパイプラインをデプロイします:
Bashdatabricks bundle deploy
- 次のノートブックを Databricks ワークスペースにインポートします。
-
1番目と2番目のセルはそのままにしておきます。変更しないでください。
-
パイプライン構成の詳細に合わせてセル 3 を変更します。パイプライン.ingestion_definition を参照してください。および 例。
-
必要に応じて、高度なパイプライン設定を行います。管理された取り込みパイプラインの一般的なパターンを参照してください。
-
「 すべて実行 」をクリックします。
例
Shopify コネクタにより、defaultソーススキーマで 39 個のソーステーブルを利用できるようになります。個別のテーブルまたはスキーマ全体を取り込みます。
特定のテーブルを取り込む
このオプションを使用して、テーブルの特定のサブセットを取り込むか、テーブルごとの宛先名をカスタマイズします。
- Declarative Automation Bundles
- Databricks notebook
次のパイプライン定義ファイルは、Shopify の個別のテーブルを取り込みます。
resources:
pipelines:
shopify_pipeline:
name: shopify_pipeline
catalog: 'main'
target: 'shopify_data'
ingestion_definition:
connection_name: shopify_connection
objects:
- table:
source_schema: 'default'
source_table: 'products'
destination_catalog: 'main'
destination_schema: 'shopify_data'
destination_table: 'products'
- table:
source_schema: 'default'
source_table: 'orders'
destination_catalog: 'main'
destination_schema: 'shopify_data'
destination_table: 'orders'
- table:
source_schema: 'default'
source_table: 'customers'
destination_catalog: 'main'
destination_schema: 'shopify_data'
destination_table: 'customers'
次のパイプライン仕様では、個別の Shopify テーブルを取り込みます。
pipeline_name = "shopify_pipeline"
connection_name = "<shopify-connection>"
pipeline_spec = {
"name": pipeline_name,
"ingestion_definition": {
"connection_name": connection_name,
"objects": [
{
"table": {
"source_schema": "default",
"source_table": "products",
"destination_catalog": "main",
"destination_schema": "shopify_data",
"destination_table": "products"
}
},
{
"table": {
"source_schema": "default",
"source_table": "orders",
"destination_catalog": "main",
"destination_schema": "shopify_data",
"destination_table": "orders"
}
},
{
"table": {
"source_schema": "default",
"source_table": "customers",
"destination_catalog": "main",
"destination_schema": "shopify_data",
"destination_table": "customers"
}
}
]
}
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
特定の一覧の起動日から取り込む
初回同期時にインクリメンタル テーブルがどのくらい過去まで読み込むかを制御するには、start_datetime オプションを使用します。
- Declarative Automation Bundles
- Databricks notebook
The following パイプライン definition file ingests Shopify tables from a specific 起動 date:
resources:
pipelines:
shopify_pipeline:
name: shopify_pipeline
catalog: 'main'
target: 'shopify_data'
ingestion_definition:
connection_name: shopify_connection
source_configurations:
- api_source_connector_config:
configs:
start_datetime: '<start-datetime>'
objects:
- table:
source_schema: 'default'
source_table: 'products'
destination_catalog: 'main'
destination_schema: 'shopify_data'
destination_table: 'products'
- table:
source_schema: 'default'
source_table: 'orders'
destination_catalog: 'main'
destination_schema: 'shopify_data'
destination_table: 'orders'
次のパイプライン仕様では、指定した開始日からShopifyテーブルを取り込みます。
pipeline_name = "shopify_pipeline"
connection_name = "<shopify-connection>"
pipeline_spec = {
"name": pipeline_name,
"ingestion_definition": {
"connection_name": connection_name,
"source_configurations": [
{
"api_source_connector_config": {
"configs": {
"start_datetime": "<start-datetime>"
}
}
}
],
"objects": [
{
"table": {
"source_schema": "default",
"source_table": "products",
"destination_catalog": "main",
"destination_schema": "shopify_data",
"destination_table": "products"
}
},
{
"table": {
"source_schema": "default",
"source_table": "orders",
"destination_catalog": "main",
"destination_schema": "shopify_data",
"destination_table": "orders"
}
}
]
}
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
スキーマ全体を取り込む
このオプションを使用すると、1 つの宣言ですべての Shopify ソース テーブルを単一の宛先スキーマに取り込むことができます。
- Declarative Automation Bundles
- Databricks notebook
以下のパイプライン定義ファイルは、サポートされているすべての Shopify テーブルを送信先スキーマに取り込みます。
resources:
pipelines:
shopify_pipeline:
name: shopify_pipeline
catalog: 'main'
target: 'shopify_data'
ingestion_definition:
connection_name: shopify_connection
objects:
- schema:
source_schema: 'default'
destination_catalog: 'main'
destination_schema: 'shopify_data'
次のパイプライン仕様では、サポートされているすべての Shopify テーブルが送信先スキーマに取り込まれます。
pipeline_name = "shopify_pipeline"
connection_name = "<shopify-connection>"
pipeline_spec = {
"name": pipeline_name,
"ingestion_definition": {
"connection_name": connection_name,
"objects": [
{
"schema": {
"source_schema": "default",
"destination_catalog": "main",
"destination_schema": "shopify_data"
}
}
]
}
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
Declarative Automation Bundles ジョブ definition file
以下は、宣言型オートメーションバンドルで使用するジョブ定義ファイルの例です。ジョブは毎日実行されます。
- Declarative Automation Bundles
resources:
jobs:
shopify_job:
name: shopify_job
schedule:
quartz_cron_expression: '0 0 0 * * ?'
timezone_id: 'UTC'
tasks:
- task_key: shopify_ingestion
pipeline_task:
pipeline_id: ${resources.pipelines.shopify_pipeline.id}
一般的なパターン
高度なパイプラインの設定については、「管理対象インジェストパイプラインの一般的なパターン」を参照してください。
次のステップ
パイプラインの起動、スケジュール、アラートの設定を行います。一般的なパイプラインのメンテナンス タスクを参照してください。