1515 from databricks .sql .client import Cursor
1616
1717from databricks .sql .thrift_api .TCLIService import ttypes
18- from databricks .sql .backend .types import SessionId , CommandId
18+ from databricks .sql .backend .types import SessionId , CommandId , CommandState
1919from databricks .sql .utils import ExecuteResponse
2020from databricks .sql .types import SSLOptions
2121
22+ # Forward reference for type hints
23+ from typing import TYPE_CHECKING
24+
25+ if TYPE_CHECKING :
26+ from databricks .sql .result_set import ResultSet
27+
2228
2329class DatabricksClient (ABC ):
2430 # == Connection and Session Management ==
@@ -81,7 +87,7 @@ def execute_command(
8187 parameters : List [ttypes .TSparkParameter ],
8288 async_op : bool ,
8389 enforce_embedded_schema_correctness : bool ,
84- ) -> Optional [ ExecuteResponse ]:
90+ ) -> Union [ "ResultSet" , None ]:
8591 """
8692 Executes a SQL command or query within the specified session.
8793
@@ -101,7 +107,7 @@ def execute_command(
101107 enforce_embedded_schema_correctness: Whether to enforce schema correctness
102108
103109 Returns:
104- If async_op is False, returns an ExecuteResponse object containing the
110+ If async_op is False, returns a ResultSet object containing the
105111 query results and metadata. If async_op is True, returns None and the
106112 results must be fetched later using get_execution_result().
107113
@@ -130,7 +136,7 @@ def cancel_command(self, command_id: CommandId) -> None:
130136 pass
131137
132138 @abstractmethod
133- def close_command (self , command_id : CommandId ) -> ttypes . TStatus :
139+ def close_command (self , command_id : CommandId ) -> None :
134140 """
135141 Closes a command and releases associated resources.
136142
@@ -140,17 +146,14 @@ def close_command(self, command_id: CommandId) -> ttypes.TStatus:
140146 Args:
141147 command_id: The command identifier to close
142148
143- Returns:
144- ttypes.TStatus: The status of the close operation
145-
146149 Raises:
147150 ValueError: If the command ID is invalid
148151 OperationalError: If there's an error closing the command
149152 """
150153 pass
151154
152155 @abstractmethod
153- def get_query_state (self , command_id : CommandId ) -> ttypes . TOperationState :
156+ def get_query_state (self , command_id : CommandId ) -> CommandState :
154157 """
155158 Gets the current state of a query or command.
156159
@@ -160,7 +163,7 @@ def get_query_state(self, command_id: CommandId) -> ttypes.TOperationState:
160163 command_id: The command identifier to check
161164
162165 Returns:
163- ttypes.TOperationState : The current state of the command
166+ CommandState : The current state of the command
164167
165168 Raises:
166169 ValueError: If the command ID is invalid
@@ -175,7 +178,7 @@ def get_execution_result(
175178 self ,
176179 command_id : CommandId ,
177180 cursor : "Cursor" ,
178- ) -> ExecuteResponse :
181+ ) -> "ResultSet" :
179182 """
180183 Retrieves the results of a previously executed command.
181184
@@ -187,7 +190,7 @@ def get_execution_result(
187190 cursor: The cursor object that will handle the results
188191
189192 Returns:
190- ExecuteResponse : An object containing the query results and metadata
193+ ResultSet : An object containing the query results and metadata
191194
192195 Raises:
193196 ValueError: If the command ID is invalid
@@ -203,7 +206,7 @@ def get_catalogs(
203206 max_rows : int ,
204207 max_bytes : int ,
205208 cursor : "Cursor" ,
206- ) -> ExecuteResponse :
209+ ) -> "ResultSet" :
207210 """
208211 Retrieves a list of available catalogs.
209212
@@ -217,7 +220,7 @@ def get_catalogs(
217220 cursor: The cursor object that will handle the results
218221
219222 Returns:
220- ExecuteResponse : An object containing the catalog metadata
223+ ResultSet : An object containing the catalog metadata
221224
222225 Raises:
223226 ValueError: If the session ID is invalid
@@ -234,7 +237,7 @@ def get_schemas(
234237 cursor : "Cursor" ,
235238 catalog_name : Optional [str ] = None ,
236239 schema_name : Optional [str ] = None ,
237- ) -> ExecuteResponse :
240+ ) -> "ResultSet" :
238241 """
239242 Retrieves a list of schemas, optionally filtered by catalog and schema name patterns.
240243
@@ -250,7 +253,7 @@ def get_schemas(
250253 schema_name: Optional schema name pattern to filter by
251254
252255 Returns:
253- ExecuteResponse : An object containing the schema metadata
256+ ResultSet : An object containing the schema metadata
254257
255258 Raises:
256259 ValueError: If the session ID is invalid
@@ -269,7 +272,7 @@ def get_tables(
269272 schema_name : Optional [str ] = None ,
270273 table_name : Optional [str ] = None ,
271274 table_types : Optional [List [str ]] = None ,
272- ) -> ExecuteResponse :
275+ ) -> "ResultSet" :
273276 """
274277 Retrieves a list of tables, optionally filtered by catalog, schema, table name, and table types.
275278
@@ -287,7 +290,7 @@ def get_tables(
287290 table_types: Optional list of table types to filter by (e.g., ['TABLE', 'VIEW'])
288291
289292 Returns:
290- ExecuteResponse : An object containing the table metadata
293+ ResultSet : An object containing the table metadata
291294
292295 Raises:
293296 ValueError: If the session ID is invalid
@@ -306,7 +309,7 @@ def get_columns(
306309 schema_name : Optional [str ] = None ,
307310 table_name : Optional [str ] = None ,
308311 column_name : Optional [str ] = None ,
309- ) -> ExecuteResponse :
312+ ) -> "ResultSet" :
310313 """
311314 Retrieves a list of columns, optionally filtered by catalog, schema, table, and column name patterns.
312315
@@ -324,7 +327,7 @@ def get_columns(
324327 column_name: Optional column name pattern to filter by
325328
326329 Returns:
327- ExecuteResponse : An object containing the column metadata
330+ ResultSet : An object containing the column metadata
328331
329332 Raises:
330333 ValueError: If the session ID is invalid
0 commit comments