2025-11-13 22:21:35 +09:00

68 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Apache Airflow
データ処理やバッチ処理(ETL/ELT)などのワークフローを
管理・自動化するためのもっとも有名なプラットフォームです。
* **できること・強み**
* Airflow は 本番の大規模ETLで強い
* ワークフローをコード(Python)で記述できる(DAG)
* スケジューラで定期実行できる
* 失敗時のリトライ・アラートが強い
* Web UIが強力
* プラグインが豊富で拡張性が高い
## ワークフローを記述する
Airflowの最大特徴はDAG(有向非巡回グラフ)という構造で
処理の流れをコード化できること。
DAG(Directed Acyclic Graph)とは
“順序や依存関係を持つタスクの集合” のこと。
```python
with DAG("my_etl_job") as dag:
extract >> transform >> load
```
* Directed(有向) → 流れに向きがある(A → B → C)
* Acyclic(非巡回) → ループしてはいけない(戻ってきてはいけない)
* Graph(グラフ) → ノード(タスク)と線(依存)で表す
```mermaid
flowchart LR
source1[("データソース1<br/>MySQL")]
source2[("データソース2<br/>API")]
source3[("データソース3<br/>CSV")]
extract["Extract<br/>データ抽出"]
transform["Transform<br/>データ変換"]
load["Load<br/>データ格納"]
dwh[("データウェア<br/>ハウス")]
source1 --> extract
source2 --> extract
source3 --> extract
extract --> transform
transform --> load
load --> dwh
```
### Taskタスク
DAG内で実行される個々の処理単位。
データ処理やスクリプト実行などを担当する
---
## Develop
### 環境を準備する
## Link
* https://airflow.apache.org/docs/apache-airflow/stable/howto/variable.html
* https://zenn.dev/iwatagumi/articles/c8c61771ae49fc