pankajkoti commented on code in PR #48507:
URL: https://github.com/apache/airflow/pull/48507#discussion_r2024273364


##########
providers/databricks/src/airflow/providers/databricks/hooks/databricks.py:
##########
@@ -189,6 +189,65 @@ def from_json(cls, data: str) -> ClusterState:
         return ClusterState(**json.loads(data))
 
 
+class SQLStatementState:
+    """Utility class for the SQL statement state concept of Databricks 
statements."""
+
+    SQL_STATEMENT_LIFE_CYCLE_STATES = [
+        "PENDING",
+        "RUNNING",
+        "SUCCEEDED",
+        "FAILED",
+        "CANCELED",
+        "CLOSED",
+    ]
+
+    def __init__(
+        self, state: str = "", error_code: str = "", error_message: str = "", 
*args, **kwargs
+    ) -> None:
+        if state not in self.SQL_STATEMENT_LIFE_CYCLE_STATES:
+            raise AirflowException(
+                f"Unexpected SQL statement life cycle state: {state}: If the 
state has "
+                "been introduced recently, please check the Databricks user "
+                "guide for troubleshooting information"
+            )
+
+        self.state = state
+        self.error_code = error_code
+        self.error_message = error_message
+
+    @property
+    def is_terminal(self) -> bool:
+        """True if the current state is a terminal state."""
+        return self.state in ("SUCCEEDED", "FAILED", "CANCELED", "CLOSED")
+
+    @property
+    def is_running(self) -> bool:
+        """True if the current state is running."""
+        return self.state in ("PENDING", "RUNNING")
+
+    @property
+    def is_successful(self) -> bool:
+        """True if the state is SUCCEEDED."""
+        return self.state == "SUCCEEDED"
+
+    def __eq__(self, other) -> bool:
+        return (
+            self.state == other.state
+            and self.error_code == other.error_code
+            and self.error_message == other.error_message
+        )

Review Comment:
   added similar to RunState



##########
providers/databricks/docs/operators/sql_statements.rst:
##########
@@ -0,0 +1,57 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+.. _howto/operator:DatabricksSQLStatementsOperator:
+
+
+DatabricksSQLStatementsOperator
+===============================
+
+Use the 
:class:`~airflow.providers.databricks.operators.databricks.DatabricksSQLStatementsOperator`
 to submits a

Review Comment:
   corrected



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