I am completely new to AirFlow and I am trying to create 8 tasks which are pretty simillar.
I've read about expand() methond though I am not quite sure how to use it for PostgresOperator?
So I have this task:
t1 = PostgresOperator(
task_id='load_something_1',
postgres_conn_id="postgres_default",
sql = "SELECT somefunction_1()",
dag=dag)
I need to create similar tasks only they gotta have load_something_2, load_something_3 etc. and SELECT somefucntion_2, SELECT somefucntion_3 etc.
How do I do this using dynamic task mapping ?
Thank you beforehand!
It's hard to say whether you need
expand()or not without knowing what your iterator looks like, and how the data is made available to the DAG, but here's how this could be accomplished with a simple iterator in a full-example DAG:Note: just calling your task like
if you want to explicitly name the tasks, you can do so using the 
my_tasks = [load_something(i) for i in range(1,9)]with the @task decorator will automatically enumerate your task names for you:override()method. Uncomment outmy_tasks = [load_something.override(task_id=f'load_something_{i}')(i) for i in range(1,9)]: