# What's Operators?
- Operator တွေက Airflow workflow တစ်ခုအတွင်းမှာ အသုံးပြုမယ့် Single Task တစ်ခုရဲ့ လုပ်ဆောင်ရမယ့် သဘောတရား (logic) ကို ခြုံငုံထည့်သွင်းထားတဲ့ predefined template တစ်ခု ဖြစ်ပါတယ်။ Operators တွေက code ကို အမှန်တကယ် execute မလုပ်ပါဘူး။ ဒါပေမယ့် အဲဒီ Code ကို Task တစ်ခုကနေ ဘယ်လို execute လုပ်မလဲဆိုတာကို ဖော်ပြပါတယ်။
- ဒါကြောင့် များသောအားဖြင့် Operator တစ်ခုက Worflow တစ်ခုမှာ Task တစ်ခုထဲကိုပဲ ကိုယ်စားပြုပါတယ်။ နောက်ပြီး များသောအားဖြင့် အချင်းချင်း independently အမှီအခိုကင်းစွာ run ပါတယ်။ ဒါအပြင် Operator အချင်းချင်းကြားမှာ information/data မျှဝေပေးတာမျိုး မရှိပါဘူး။
- Operators တွေကို ယေဘုယျအနေဖြင့် အောက်ပါ ပုံ အတိုင်း အုပ်စု ၃ ခု ခွဲလို့ ရပါတယ်။ ![[Pasted image 20250429225305.png|500]]
### PythonOperator
- ယခင် PythonOperator ကို အသုံးပြုပြီး ရေးသားသည့် ပုံစံ
```python
from airflow.operators.python import PythonOperator
# Create the task
pull_file_task = PythonOperator(
task_id='pull_file',
# Add the callable
python_callable=pull_file,
# Define the arguments
op_kwargs={'URL':'http://dataserver/sales.json', 'savepath':'latestsales.json'}
)
```
- ယခု `@task` decorator ကို အသုံးပြုပြီး ရေးသားရမည့် ပုံစံသစ်
### BashOperator
# What's Tasks?
Task ဆိုတာက Operator (template) ကို အသုံးပြုပြီး တည်ဆောက်ထားတဲ့ အရာလို့ ပြောလို့ ရပါတယ်။
### Task Dependency
Upstream / Downstream ဆိုတဲ့ Task Dependencies အကြောင်း ကိုလဲ သိထားဖို့ လိုပါတယ်။ Upstream ဆိုတာက **before** (လက်ရှိ task မတိုင်ခင် အရှေ့က အရင် execute လုပ်ခဲ့ရတဲ့ task) ကို ဆိုလိုပြီး Download ဆိုတာကတော့ **after** (လက်ရှိ task အပြီးမှ ဆက်လက် execute လုပ်ရမယ့် task) ကို ဆိုလိုပါတယ်။