ha2hi commented on code in PR #64766:
URL: https://github.com/apache/airflow/pull/64766#discussion_r3192098687


##########
providers/databricks/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -410,6 +410,54 @@ def execute(self, context: Context) -> int:
         return job_id
 
 
+class DatabricksDeleteJobsOperator(BaseOperator):
+    """
+    Deletes a Databricks job.
+
+    :param job_id: The ID of the Databricks job to delete. (templated)
+    :param databricks_conn_id: Reference to the Databricks connection.
+    :param databricks_retry_limit: Amount of times retry if the Databricks 
backend is unreachable.
+        Its value must be greater than or equal to 1.
+    :param databricks_retry_delay: Number of seconds to wait between retries 
(it
+        might be a floating point number).
+    :param databricks_retry_args: An optional dictionary with arguments passed 
to ``tenacity.Retrying``.
+    """
+
+    template_fields: Sequence[str] = ("job_id",)
+
+    def __init__(
+        self,
+        *,
+        job_id: int | str,
+        databricks_conn_id: str = "databricks_default",
+        databricks_retry_limit: int = 3,
+        databricks_retry_delay: int = 1,
+        databricks_retry_args: dict[Any, Any] | None = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        self.job_id = job_id
+        self.databricks_conn_id = databricks_conn_id
+        self.databricks_retry_limit = databricks_retry_limit
+        self.databricks_retry_delay = databricks_retry_delay
+        self.databricks_retry_args = databricks_retry_args
+
+    @cached_property
+    def _hook(self):
+        return DatabricksHook(
+            self.databricks_conn_id,
+            retry_limit=self.databricks_retry_limit,
+            retry_delay=self.databricks_retry_delay,
+            retry_args=self.databricks_retry_args,
+            caller="DatabricksDeleteJobsOperator",
+        )
+
+    def execute(self, context: Context) -> None:
+        self._hook.delete_job(self.job_id)

Review Comment:
   Thanks for the suggestion.
   I’ll incorporate it.



-- 
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