Operators

Operators define the work to be performed in a task. Airflow ships with a rich set of built‑in operators, and you can also create custom operators for your own logic.

BashOperator

Executes a Bash command or script.

Read more →

PythonOperator

Calls a Python callable.

Read more →

DockerOperator

Runs a task in a Docker container.

Read more →

SQLExecuteOperator

Executes SQL statements against a database.

Read more →

TriggerDagRunOperator

Triggers another DAG run.

Read more →

SimpleHttpOperator

Performs an HTTP request.

Read more →

BranchPythonOperator

Chooses a downstream path based on a Python function.

Read more →

CustomOperator

Guidelines for building your own operator.

Read more →

Common Patterns

Below are snippets showing typical usage patterns for several operators.

# BashOperator example
from airflow import DAG
from airflow.providers.bash.operators.bash import BashOperator
from datetime import datetime

with DAG('example_bash', start_date=datetime(2023,1,1), schedule_interval='@daily') as dag:
    t1 = BashOperator(
        task_id='print_date',
        bash_command='date'
    )
# PythonOperator example
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime

def greet():
    print("Hello from Airflow!")

with DAG('example_python', start_date=datetime(2023,1,1), schedule_interval='@once') as dag:
    greet_task = PythonOperator(
        task_id='greet',
        python_callable=greet
    )