BigData / Apache Airflow Interview Questions
What is branching in Airflow and how is BranchPythonOperator used?
Branching lets a DAG conditionally execute one or more downstream paths based on runtime logic. The BranchPythonOperator runs a Python callable that returns the task_id (or list of task_ids) of the branch(es) to follow. All other branches are skipped.
from airflow.operators.python import BranchPythonOperator
def choose_branch():
import random
return 'branch_a' if random.random() > 0.5 else 'branch_b'
branch = BranchPythonOperator(
task_id='choose',
python_callable=choose_branch
)
branch >> [task_a, task_b]
Tasks not selected by the branch get a skipped state, so downstream join tasks often need trigger_rule='none_failed_min_one_success'.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
