amoghrajesh commented on code in PR #76295:
URL: https://github.com/apache/airflow/pull/76295#discussion_r4509161457


##########
providers/databricks/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -82,6 +82,45 @@
 XCOM_RUN_PAGE_URL_KEY = "run_page_url"
 XCOM_STATEMENT_ID_KEY = "statement_id"
 
+# Databricks splits run state across life_cycle_state and result_state, while 
the ResumableJobMixin
+# status interface is a single string. The durable operators encode both as 
"LIFE_CYCLE:RESULT" and
+# decode them with the predicates below, so all three share one view of which 
runs can be rejoined.
+RUN_NOT_FOUND_STATUS = "NOT_FOUND:"
+ACTIVE_RUN_LIFE_CYCLE_STATES = (
+    "PENDING",
+    "QUEUED",
+    "RUNNING",
+    "TERMINATING",
+    "BLOCKED",
+    "WAITING_FOR_RETRY",
+)
+
+
+def fetch_run_status(hook: DatabricksHook, run_id: JsonValue) -> str:
+    """Return the encoded status of ``run_id``, or a sentinel if its run 
history is gone."""
+    try:
+        # The stored external id is always a Databricks run id; the mixin 
types it as JsonValue.
+        run_info = hook.get_run(cast("int", run_id))
+    except DatabricksApiError as e:
+        # A stored run whose history expired (or was deleted) returns 404. The 
sentinel is neither
+        # active nor succeeded, so the mixin resubmits fresh instead of 
failing the task.
+        if e.http_status_code == 404:

Review Comment:
   Fixing it in a precursor: https://github.com/apache/airflow/pull/76718



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to