Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
dbtをAirflowで動かす道のりは続く...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuu.Kimy
November 28, 2023
Technology
940
0
Share
dbtをAirflowで動かす道のりは続く...
タイミーさんとの合同勉強会で発表させて頂いた資料です。
dbt CoreをAirflow(Cloud Composer)で動かした時の検証結果をまとめています。
Yuu.Kimy
November 28, 2023
More Decks by Yuu.Kimy
See All by Yuu.Kimy
Scheduled Queryの運用を楽にするBotを実装してみたお話
yuukimiya
0
200
Airflow社内勉強会@Classi
yuukimiya
0
200
DPCT発表資料.pdf
yuukimiya
0
9.7k
お家で子どもと楽しむプログラミング
yuukimiya
0
1.4k
Other Decks in Technology
See All in Technology
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
2
240
バックオフィスPJのPjMをコーポレートITが担うとうまくいく3つの理由
yueda256
1
290
組織的なAI活用を阻む 最大のハードルは コンテキストデザインだった
ixbox
1
1k
I ran an automated simulation of fake news spread using OpenClaw.
zzzzico
1
980
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
17k
機能・非機能の学びを一つに!Agent Skillsで月間レポート作成始めてみた / Unifying Bug & Infra Insights — Building Monthly Quality Reports with Agent Skills
bun913
5
3.6k
プロダクトを育てるように生成AIによる開発プロセスを育てよう
kakehashi
PRO
1
830
解剖"React Native"
hacusk
0
120
2026-04-02 IBM Bobオンボーディング入門
yutanonaka
0
250
Babylon.js Japan Activities (2026/4)
limes2018
0
190
自己組織化を試される緑茶ハイを求めて、今日も全力であそんで学ぼう / Self-Organization and Shochu Green Tea
naitosatoshi
0
240
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
Featured
See All Featured
KATA
mclloyd
PRO
35
15k
The Limits of Empathy - UXLibs8
cassininazir
1
290
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
4 Signs Your Business is Dying
shpigford
187
22k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
310
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
300
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Transcript
dbtをAirflowで動かす道のりは続く... 分析推進室 Kimiya Yuu
本日のお話 • タイトルの通り、dbt(dbt Core)をAirflowで動かすことを奮闘した記録です。 • まだ、検証段階ですので、不正確な情報が含まれているかもしれません。 ご了承くださいm(_ _)m
背景 • これまでAirflow(Cloud Composer)にて、定常的なバッチ更新で運用してきた。 ◦ 基本は、BigQueryに対するデータ更新処理 • ただ、日常の開発は、やり辛さが発生しており、開発体験が悪い.. ◦ ➜
dbtによる開発に切り替えたい • ただし、定常運用は、既に、オペレーションとしては確立しており、 大きくは変更したくない。 ➜ 学習コストがかかり、キャッチアップに時間がかかるため。 • 上記を踏まえ、dbtをAirflowで動かてみたい!
検討 • 以下の方式が考えられる • 折角、導入するのであれば、dbtで出来る体験をAirflowに持ち込みたい ➜ 上記により、#3で決定 ➜ 個人的に使ってみたかったというのも大いにありw #
dbt 実行概要 気になるポイント 1 dbt Core BashOperator利用 BashOperatorに閉じてしまう.. 2 dbt Cloud DbtCloudRunJobOperator利用 dbt Cloudをまだ導入していない ..& 同上 3 dbt Core Cosmosパッケージ利用 dbtのモデルもDAGの依存関係として表示可
What’s Cosmos ?? • Astronomer社が提供しているOSSであり、Airflow上でdbtを動かすことが可能 • Airflowの画面UIで、dbtのモデルのリネージを可視化できる! 参考: https://astronomer.github.io/astronomer-cosmos/index.html
環境 • 現状、利用している環境を踏まえて、以下を選択 • ※今、弊社で利用しているComposerで動いているAirflowのバージョンと Cosmosのバージョンで、Python的にはコンフリクトすることは無さそう🤗 ◦ Airflow: Cloud Composer
ver. 2.1.14 ◦ Cosmos: ver.1.2.0 ◦ dbt Core: ver.1.3.7 ◦ dbt-bigquery: ver.1.3.0 参考: https://astronomer.github.io/astronomer-cosmos/getting_started/execution-modes-local-conflicts.html
設定・実装 • 設定 ◦ Composer側に、PyPIからCosmosパッケージをインストールする ◦ GCSのディレクトリ構成は以下の通り • 実装 ◦
ドキュメントを参考に、DbtTaskGroup を利用して、 dbtのモデルの実行処理を実装する
ハマったこと • ドキュメント通りに実装しても、エラーが発生した... ◦ ドキュメント&コードはそれなりに読む必要がある ▪ 例: stringで渡すと書いてあったのに、 Pathオブジェクトで渡す必要があり.. (後述)
• dbt -> BigQueryの認証は、profiles.yml を渡して、ProfileConfigを生成すると、 json keyを利用しなくてもOK ◦ profiles.ymlには、BigQueryの実行権限を持つプロジェクトを指定 ◦ 事前に作成していないデータセットに、モデル結果を保存させると、 データセットまで作成するので、データセット生成の権限がないとエラー..
結果 ※補足: 上記の結果は、裏側では、dbt run が実行されている状態。dbt testは試していないですm(_ _)m
参考1
参考2
考察 • 既に、dbtのモデルの運用していたとしても、Cosmosを使った事前検証は必要 • AirflowのDAGの中で、dbtのモデルを表現できるのは強みと思しき ◦ dbtを利用する際は、基本的に、dbtのモデルを意識すれば良い • dbtのプロジェクトをDAGごとに分離できるのも強み ◦
完全に分離するのであれば、Docker/k8sを検討するのが良いと思しき ◦ ↑ただし、モデルの実行時間(全体)が長くなりそう.. • 小〜中規模なデータ分析基盤であれば、dbt + Cosmos + Airflowで十分かも ◦ 今年(2023年)にリリースされ、結構ホットなOSSであるが、 本番利用は慎重に検討したほうが良さそうな予感,,
Thank you for your attention !!