Switch
Marks a task method that chooses one of several tasks to run; every other one is skipped.
The method returns the class the Dag's builder generated for the task it chose, as Class<? extends Task>. Its wiring-view method returns a SwitchRef, so the cases are listed where the Dag is wired:
@Airflow.Switch(id = "pick_path")
public Class<? extends Task> pickPath(long rows) {
return rows > 1000 ? EtlBuilder.HandleLong.class : EtlBuilder.HandleShort.class;
}
@Airflow.Deps
static class Wiring implements EtlDeps {
void depends() { pickPath(extract()).Case(handleLong()).Case(handleShort()); }
}A switch chooses exactly one case, so a task that runs after several of them needs a trigger rule that tolerates a skipped upstream, such as none_failed_min_one_success.
Configuration attributes are Task's, and apply to the deciding task.
Properties
Airflow's depends_on_past setting.
Airflow's do_xcom_push setting.
Airflow's email_on_failure setting.
Airflow's email_on_retry setting.
Airflow's execution_timeout setting; an ISO-8601 duration such as "PT5M".
Airflow's ignore_first_depends_on_past setting.
Airflow's map_index_template setting.
Airflow's max_active_tis_per_dag setting.
Airflow's max_active_tis_per_dagrun setting.
Airflow's max_retry_delay setting; an ISO-8601 duration such as "PT5M".
Airflow's priority_weight setting.
Airflow's retry_delay setting; an ISO-8601 duration such as "PT5M".
Airflow's retry_exponential_backoff setting.
Airflow's trigger_rule setting.
Airflow's wait_for_downstream setting.
Airflow's wait_for_past_depends_before_skipping setting.
Airflow's weight_rule setting.