airflow.providers.databricks.triggers.databricks

Classes

DatabricksExecutionTrigger

The trigger handles the logic of async communication with DataBricks API.

DatabricksSQLStatementExecutionTrigger

The trigger handles the logic of async communication with DataBricks SQL Statements API.

DatabricksWarehouseStateTrigger

Poll a Databricks SQL warehouse until it reaches a target lifecycle state.

Module Contents

class airflow.providers.databricks.triggers.databricks.DatabricksExecutionTrigger(run_id, databricks_conn_id, polling_period_seconds=30, retry_limit=3, retry_delay=10, retry_args=None, run_page_url=None, repair_run=False, caller='DatabricksExecutionTrigger', workflow_run_id=None, databricks_task_key=None, max_retries=None)[source]

Bases: airflow.triggers.base.BaseTrigger

The trigger handles the logic of async communication with DataBricks API.

Parameters:
  • run_id (int) – id of the run

  • databricks_conn_id (str) – Reference to the Databricks connection.

  • polling_period_seconds (int) – Controls the rate of the poll for the result of this run. By default, the trigger will poll every 30 seconds.

  • retry_limit (int) – The number of times to retry the connection in case of service outages.

  • retry_delay (int) – Minimum wait in seconds between retryable attempts when using the default retry strategy. The wait uses exponential backoff (doubling after each failure, capped at 2 ** retry_limit seconds). May be a floating point number.

  • retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to tenacity.Retrying class.

  • run_page_url (str | None) – The run page url.

  • repair_run (bool) – Repair the databricks run in case of failure.

  • caller (str) – The name of the operator that is calling the hook.

  • workflow_run_id (int | None) – Parent workflow run ID for task-level monitoring.

  • databricks_task_key (str | None) – Task key to monitor within workflow_run_id.

  • max_retries (int | None) – Resolved Databricks-native max_retries for task-level monitoring.

run_id[source]
databricks_conn_id[source]
polling_period_seconds = 30[source]
retry_limit = 3[source]
retry_delay = 10[source]
retry_args = None[source]
run_page_url = None[source]
repair_run = False[source]
caller = 'DatabricksExecutionTrigger'[source]
workflow_run_id = None[source]
databricks_task_key = None[source]
max_retries = None[source]
hook[source]
serialize()[source]

Return the information needed to reconstruct this Trigger.

Returns:

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type:

tuple[str, dict[str, Any]]

async on_kill()[source]

Cancel the Databricks run when the trigger is cancelled by a user action.

async run()[source]

Run the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.databricks.triggers.databricks.DatabricksSQLStatementExecutionTrigger(statement_id, databricks_conn_id, end_time, polling_period_seconds=30, retry_limit=3, retry_delay=10, retry_args=None, caller='DatabricksSQLStatementExecutionTrigger')[source]

Bases: airflow.triggers.base.BaseTrigger

The trigger handles the logic of async communication with DataBricks SQL Statements API.

Parameters:
  • statement_id (str) – ID of the SQL statement.

  • databricks_conn_id (str) – Reference to the Databricks connection.

  • end_time (float) – The end time (set based on timeout supplied for the operator) for the SQL statement execution.

  • polling_period_seconds (int) – Controls the rate of the poll for the result of this run. By default, the trigger will poll every 30 seconds.

  • retry_limit (int) – The number of times to retry the connection in case of service outages.

  • retry_delay (int) – Minimum wait in seconds between retryable attempts when using the default retry strategy. The wait uses exponential backoff (doubling after each failure, capped at 2 ** retry_limit seconds). May be a floating point number.

  • retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to tenacity.Retrying class.

  • caller (str) – The name of the operator that is calling the hook.

statement_id[source]
databricks_conn_id[source]
end_time[source]
polling_period_seconds = 30[source]
retry_limit = 3[source]
retry_delay = 10[source]
retry_args = None[source]
caller = 'DatabricksSQLStatementExecutionTrigger'[source]
hook[source]
serialize()[source]

Return the information needed to reconstruct this Trigger.

Returns:

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type:

tuple[str, dict[str, Any]]

async on_kill()[source]

Cancel the Databricks SQL statement when the trigger is cancelled by a user action.

async run()[source]

Run the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.databricks.triggers.databricks.DatabricksWarehouseStateTrigger(warehouse_id, target_state, databricks_conn_id, end_time, polling_period_seconds=30, retry_limit=3, retry_delay=10, retry_args=None, caller='DatabricksWarehouseStateTrigger')[source]

Bases: airflow.triggers.base.BaseTrigger

Poll a Databricks SQL warehouse until it reaches a target lifecycle state.

Databricks has no cancel API for warehouse start or stop, so this trigger does not override on_kill. Clearing a deferred wait leaves warehouse state unchanged.

Parameters:
  • warehouse_id (str) – ID of the Databricks SQL warehouse.

  • target_state (str) – Lifecycle state to wait for (RUNNING or STOPPED).

  • databricks_conn_id (str) – Reference to the Databricks connection.

  • end_time (float) – Absolute Unix timestamp when the wait must stop. The operator sets this from timeout before deferring so a triggerer restart or HA rebalance does not reset the deadline.

  • polling_period_seconds (int) – Controls the rate of the poll for the warehouse state. By default, the trigger will poll every 30 seconds.

  • retry_limit (int) – The number of times to retry the connection in case of service outages.

  • retry_delay (int) – Minimum wait in seconds between retryable attempts when using the default retry strategy. The wait uses exponential backoff (doubling after each failure, capped at 2 ** retry_limit seconds). May be a floating point number.

  • retry_args (dict[Any, Any] | None) – An optional dictionary with arguments passed to tenacity.Retrying class.

  • caller (str) – The name of the operator that is calling the hook.

warehouse_id[source]
target_state[source]
databricks_conn_id[source]
end_time[source]
polling_period_seconds = 30[source]
retry_limit = 3[source]
retry_delay = 10[source]
retry_args = None[source]
caller = 'DatabricksWarehouseStateTrigger'[source]
hook[source]
serialize()[source]

Return the information needed to reconstruct this Trigger.

Returns:

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type:

tuple[str, dict[str, Any]]

async run()[source]

Run the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

Was this entry helpful?