Recall & Review
beginner
What is the purpose of the BashOperator in Airflow?
The BashOperator allows you to run shell commands or scripts as tasks within an Airflow workflow (DAG). It helps automate command-line operations.
Click to reveal answer
beginner
How do you specify the shell command to run in a BashOperator?
You use the 'bash_command' parameter to provide the shell command or script you want to execute.
Click to reveal answer
intermediate
What happens if the shell command run by BashOperator fails?
If the shell command exits with a non-zero status, the BashOperator marks the task as failed, which can trigger retries or alerts.
Click to reveal answer
intermediate
Can BashOperator run multi-line shell scripts?
Yes, you can pass multi-line shell scripts using triple quotes or by referencing a script file in the 'bash_command' parameter.
Click to reveal answer
intermediate
How do you pass parameters or variables to a BashOperator command?
You can use Jinja templating in the 'bash_command' to insert variables dynamically, like '{{ ds }}' for the execution date.
Click to reveal answer
Which parameter do you use to define the shell command in BashOperator?
✗ Incorrect
The 'bash_command' parameter is used to specify the shell command or script to run.
What does BashOperator do if the shell command exits with a non-zero status?
✗ Incorrect
A non-zero exit status causes the task to be marked as failed.
Can you use Jinja templating inside the bash_command parameter?
✗ Incorrect
Jinja templating is supported to insert dynamic values like execution date.
How can you run a multi-line shell script with BashOperator?
✗ Incorrect
Multi-line scripts can be passed using triple quotes or by calling an external script.
What is a common use case for BashOperator?
✗ Incorrect
BashOperator is designed to run shell commands or scripts within Airflow tasks.
Explain how to use BashOperator to run a shell command in an Airflow DAG.
Think about how you tell Airflow what shell command to run and what happens if it fails.
You got /4 concepts.
Describe how you can pass dynamic values like execution date into a BashOperator command.
Remember Airflow supports templates inside bash_command.
You got /3 concepts.