Airflow Hook vs Operator
People think a hook is just another kind of operator. A hook is a helper that logs in to one system and talks to it. It is not a task and never shows in the graph. An operator is a task. Many operators use a hook inside to do their work. When no operator fits, you call the hook from your own task.
Airflow Hook
Code that logs in to one system for you, like a database. Tasks use it.
An Airflow hook is ready-made code for talking to one outside system. There is one for PostgreSQL, one for Amazon S3 and many more. You give it a connection name, and it logs in for you. Then you call its methods to run a query or move a file. Many operators are built on top of a hook. You use a hook directly when no operator does quite what you need.
Airflow Operator
A ready-made Airflow template. Fill it in, and it becomes a task.
An Airflow operator is a ready-made template for one kind of task. One runs a shell command, one runs SQL, and one copies a file to the cloud. You fill in its settings and give it a task ID. That makes a task. Add-on packages bring templates for clouds, databases and tools. A sensor is a special one that waits.
In one line
- Airflow Hook
- Code that logs in to one system for you, like a database. Tasks use it.
- Airflow Operator
- A ready-made Airflow template. Fill it in, and it becomes a task.