Bear with me since I've just started using Airflow, and what I'm trying to do is to collect the return code from a BashOperator task and save it to a local variable, and then based on that return code branch out to another task. The issue I have is figuring out how to get the BashOperator to return something. The following is my code segment:
dag = DAG(dag_id='dag_1',
default_args=default_args,
schedule_interval='0 2 * * *',
user_defined_macros=user_def_macros,
dagrun_timeout=timedelta(minutes=60)
)
oodas = BashOperator(task_id='oodas', xcom_push=True, bash_command="hive -hiveconf SCHEMA={{ schema }} -hiveconf DAY={{ yesterday_ds }} -f {{ script_path }}", dag=dag)
t2 = BashOperator(task_id='t2', bash_command='echo "{{ ti.xcom_pull("oodas") }}"', dag=dag)
t2.set_upstream(oodas)
I'm trying the xcom_push but honestly have no idea how it works.. Is this the right way to collect the result? In the logs the last line is: Command exited with return code 0.