Airflow novice here
Setup
- env: MWAA
- db: Redshift
Question: I am trying to write a task to loop through a list, use the list value in SQL and lastly use an if statement to determine appropriate action based on the results. Something like this but struggling a bit. If it is possible what's the best way to achieve it?
def duplicate_check():
ls = ['table1','table2','table3','table4']
for tables in ls:
number_of_records = RedshiftSQLOperator(
"""
SQL which returns me one record with a int output. Number of order ID duplicates. I'd like to use pass {{tables}} though?
"""
)
if number_of_records > 0:
send_email = EmailOperator(
''
)
else:
None
start >> PythonOperator call above function >> end