Cloud Intelligence™Cloud Intelligence™

Cloud Intelligence™

Cloud Composerでdbtをセットアップ

By Vinay GandhiSep 7, 20202 min read

このページはEnglishDeutschEspañolFrançaisItalianoPortuguêsでもご覧いただけます。

本記事では、Google Cloud Composer上でdbtをセットアップする手順を順を追って解説します。

  1. はじめに、以下の環境構成でCloud Composerインスタンスを作成します。

2. Composerに以下2つのPythonパッケージをインストールします。

airflow-dbt(dbt operatorおよびdbt hook)

dbt(dbtのPythonパッケージ)

3. 次に、サービスアカウントキーファイル用の環境変数 DBT_PROFILES_DIR に 「/home/airflow/gcs/data/profiles」 を設定します。

4. 続いて、「BigQuery User」ロールを付与したサービスアカウント「dbt-big-query-user」を作成します。

前提:BigQueryのデータセットを別のBigQueryテーブルへ変換するケースを想定します。

5. 「Jaffle Shop」の公開データを使って、シンプルなdbtワークフローファイルを作成します。

6. dbt operatorでワークフローを定義します(dbtflow.py)。

7. 以下の階層でファイルをComposerバケットへアップロードします。

8. Composer上で「dbt」DAGを実行します。

9. BigQueryでdbtワークフローの実行結果を確認します。

参考リンク

上記で紹介したサンプルファイルは、https://bit.ly/3kJ4pWQ から composer-dbt.zip としてダウンロードできます。

composer-dbt.zip \ \ bit.ly

airflow-dbt \ \ This is a collection of Airflow operators to provide easy integration with dbt. Install from PyPI: pip install…\ \ pypi.org

dbt CLI: Create a project | dbt - Documentation \ \ Now that we've successfully run our sample query in BigQuery, and chosen the way we want to develop, we can create a…\ \ docs.getdbt.com

fishtown-analytics/jaffle_shop \ \ jaffle_shop is a fictional ecommerce store. This dbt project transforms raw data from an app database into a customers…\ \ github.com

Schedule dbt models with Apache Airflow | Analytics Mayhem \ \ Working with dbt certainly makes the life of an analyst much better. It brings a certain structure that without a…\ \ analyticsmayhem.com