Google 広告からデータを取り込む
ベータ版
この機能はベータ版です。ワークスペース管理者は、 プレビュー ページからこの機能へのアクセスを制御できます。「Databricks プレビューの管理」を参照してください。
Google 広告から Databricks にデータを取り込むためのマネージド取り込みパイプラインを作成する方法を学びます。
要件
-
取り込み パイプラインを作成するには、次の要件を満たす必要があります。
-
ワークスペースでUnity Catalogが有効になっている必要があります。
-
ワークスペースでサーバレスコンピュートを有効にする必要があります。 「サーバレス コンピュート要件」を参照してください。
-
新しい接続を作成する場合:メタストアに対して
CREATE CONNECTION権限が必要です。Unity Catalogの「権限の管理」を参照してください。コネクタが UI ベースのパイプライン オーサリングをサポートしている場合、管理者はこのページのステップを完了することで、接続とパイプラインを同時に作成できます。 ただし、パイプラインを作成するユーザーが API ベースのパイプライン オーサリングを使用している場合、または管理者以外のユーザーである場合、管理者はまずカタログ エクスプローラーで接続を作成する必要があります。 「管理対象取り込みソースへの接続」を参照してください。
-
既存の接続を使用する場合: 接続オブジェクトに対する
USE CONNECTION権限またはALL PRIVILEGESが必要です。 -
ターゲット カタログに対する
USE CATALOG権限が必要です。 -
既存のスキーマに対する
USE SCHEMAおよびCREATE TABLE権限、またはターゲット カタログに対するCREATE SCHEMA権限が必要です。
-
-
Google 広告から取り込むには、 「Google 広告取り込み用にOAuthを構成する」のステップを完了する必要があります。
取り込みパイプラインを作成する
- Databricks Asset Bundles
- Databricks notebook
このタブでは、宣言型自動化バンドルを使用してデータ取り込みパイプラインをデプロイする方法について説明します。バンドルにはジョブとタスクの YAML 定義を含めることができ、 Databricks CLIを使用して管理でき、さまざまなターゲット ワークスペース (開発、ステージング、本番運用など) で共有して実行できます。 詳細については、 「宣言的オートメーション バンドルとは何ですか?」を参照してください。 。
-
Databricks CLI を使用して新しいバンドルを作成します。
Bashdatabricks bundle init -
バンドルに 2 つの新しいリソース ファイルを追加します。
- パイプライン定義ファイル (例:
resources/google_ads_pipeline.yml)。 - データ取り込みの頻度を制御するジョブ定義ファイル (例:
resources/google_ads_job.yml)。
パイプライン.ingestion_定義を参照してください。 および例。
- パイプライン定義ファイル (例:
-
Databricks CLI を使用してパイプラインをデプロイします。
Bashdatabricks bundle deploy
- 次のノートブックを Databricks ワークスペースにインポートします。
-
セル 1 はそのままにしておきます。
-
ユースケースに応じて、パイプライン構成の詳細を使用してセル 2 または 3 を変更します。パイプライン.ingestion_定義を参照してください。 および例。
-
「 すべて実行 」をクリックします。
例
- Databricks Asset Bundles
- Databricks notebook
次のパイプライン定義ファイルは、1 つのアカウントから現在のテーブルと将来のテーブルをすべて取り込みます。
resources:
pipelines:
pipeline_google_ads:
name: <pipeline>
catalog: <destination-catalog>
target: <destination-schema>
ingestion_definition:
connection_name: <connection>
objects:
- schema:
source_schema: <account-id>
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
google_ads_options:
manager_account_id: <manager-account-id>
lookback_window_days: <lookback-window-days>
sync_start_date: <sync-start-date>
次のパイプライン定義ファイルは、アカウントから特定のテーブルを選択して取り込みます。
resources:
pipelines:
pipeline_google_ads:
name: <pipeline-name>
catalog: <destination-catalog>
target: <destination-schema>
ingestion_definition:
connection_name: <connection-name>
objects:
- table:
source_schema: <customer-account-id>
source_table: <table1>
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
destination_table: <destination-table>
google_ads_options:
manager_account_id: <manager-account-id>
lookback_window_days: <lookback-window-days>
sync_start_date: <sync-start-date>
- table:
source_schema: <customer-account-id>
source_table: table2
destination_catalog: <destination-catalog>
destination_schema: <destination-schema>
destination_table: <destination-table>
google_ads_options:
manager_account_id: <manager-account-id>
lookback_window_days: <lookback-window-days>
sync_start_date: <sync-start-date>
以下はジョブ定義ファイルの例です。
resources:
jobs:
google_ads_dab_job:
name: google_ads_dab_job
trigger:
# Run this job every day, exactly one day from the last run
# See https://docs.databricks.com/api/workspace/jobs/create#trigger
periodic:
interval: 1
unit: DAYS
email_notifications:
on_failure:
- <email-address>
tasks:
- task_key: refresh_pipeline
pipeline_task:
pipeline_id: <pipeline-id>
次のパイプライン仕様は、1 つのアカウントから現在のテーブルと将来のテーブルをすべて取り込みます。
pipeline_spec = {
"name": <pipeline>,
"catalog": "<destination-catalog>",
"schema": "<destination-schema>",
"ingestion_definition": {
"connection_name": <connection>,
"objects": [
{
"schema": {
"source_schema": "<account-id>",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"google_ads_options": {
"manager_account_id": "<manager-account-id>",
"lookback_window_days": <lookback-window-days>,
"sync_start_date": "<sync-start-date>"
}
}
}
]
}
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
次のパイプライン仕様では、アカウントから特定のテーブルを選択して取り込みます。
pipeline_spec = {
"name": <pipeline>,
"catalog": "<destination-catalog>",
"schema": "<destination-schema>",
"ingestion_definition": {
"connection_name": <connection>,
"objects": [
{
"table": {
"source_schema": "<customer-account-id>",
"source_table": "<table1>",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"destination_table": "<destination-table>",
"google_ads_options": {
"manager_account_id": "<manager-account-id>",
"lookback_window_days": <lookback-window-days>,
"sync_start_date": "<sync-start-date>"
}
}
},
{
"table": {
"source_schema": "<customer-account-id>",
"source_table": "table2",
"destination_catalog": "<destination-catalog>",
"destination_schema": "<destination-schema>",
"destination_table": "<destination-table>",
"google_ads_options": {
"manager_account_id": "<manager-account-id>",
"lookback_window_days": <lookback-window-days>,
"sync_start_date": "<sync-start-date>"
}
}
}
]
}
}
json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
一般的なパターン
高度なパイプライン構成については、 「管理された取り込みパイプラインの一般的なパターン」を参照してください。
次のステップ
パイプラインを開始、スケジュールし、アラートを設定します。一般的なパイプラインメンテナンスタスクを参照してください。