1111"""
1212
1313from abc import ABC , abstractmethod
14- from typing import Dict , Tuple , List , Optional , Any , Union
14+ from typing import Dict , Tuple , List , Optional , Any , Union , TYPE_CHECKING
15+
16+ if TYPE_CHECKING :
17+ from databricks .sql .client import Cursor
1518
16- from databricks .sql .client import Cursor
1719from databricks .sql .thrift_api .TCLIService import ttypes
1820from databricks .sql .backend .types import SessionId , CommandId
1921from databricks .sql .utils import ExecuteResponse
@@ -76,7 +78,7 @@ def execute_command(
7678 max_rows : int ,
7779 max_bytes : int ,
7880 lz4_compression : bool ,
79- cursor : Cursor ,
81+ cursor : " Cursor" ,
8082 use_cloud_fetch : bool ,
8183 parameters : List [ttypes .TSparkParameter ],
8284 async_op : bool ,
@@ -174,7 +176,7 @@ def get_query_state(self, command_id: CommandId) -> ttypes.TOperationState:
174176 def get_execution_result (
175177 self ,
176178 command_id : CommandId ,
177- cursor : Cursor ,
179+ cursor : " Cursor" ,
178180 ) -> ExecuteResponse :
179181 """
180182 Retrieves the results of a previously executed command.
@@ -202,13 +204,13 @@ def get_catalogs(
202204 session_id : SessionId ,
203205 max_rows : int ,
204206 max_bytes : int ,
205- cursor : Cursor ,
207+ cursor : " Cursor" ,
206208 ) -> ExecuteResponse :
207209 """
208210 Retrieves a list of available catalogs.
209211
210- This method fetches metadata about the catalogs that are available
211- in the current session.
212+ This method fetches metadata about all catalogs available in the current
213+ session's context .
212214
213215 Args:
214216 session_id: The session identifier
@@ -231,23 +233,23 @@ def get_schemas(
231233 session_id : SessionId ,
232234 max_rows : int ,
233235 max_bytes : int ,
234- cursor : Cursor ,
236+ cursor : " Cursor" ,
235237 catalog_name : Optional [str ] = None ,
236238 schema_name : Optional [str ] = None ,
237239 ) -> ExecuteResponse :
238240 """
239- Retrieves a list of available schemas.
241+ Retrieves a list of schemas, optionally filtered by catalog and schema name patterns .
240242
241- This method fetches metadata about the schemas that are available
242- in the specified catalog.
243+ This method fetches metadata about schemas available in the specified catalog
244+ or all catalogs if no catalog is specified .
243245
244246 Args:
245247 session_id: The session identifier
246248 max_rows: Maximum number of rows to fetch in a single batch
247249 max_bytes: Maximum number of bytes to fetch in a single batch
248250 cursor: The cursor object that will handle the results
249- catalog_name: Optional catalog name to filter schemas
250- schema_name: Optional schema pattern to filter schemas by name
251+ catalog_name: Optional catalog name pattern to filter by
252+ schema_name: Optional schema name pattern to filter by
251253
252254 Returns:
253255 ExecuteResponse: An object containing the schema metadata
@@ -264,27 +266,27 @@ def get_tables(
264266 session_id : SessionId ,
265267 max_rows : int ,
266268 max_bytes : int ,
267- cursor : Cursor ,
269+ cursor : " Cursor" ,
268270 catalog_name : Optional [str ] = None ,
269271 schema_name : Optional [str ] = None ,
270272 table_name : Optional [str ] = None ,
271273 table_types : Optional [List [str ]] = None ,
272274 ) -> ExecuteResponse :
273275 """
274- Retrieves a list of available tables.
276+ Retrieves a list of tables, optionally filtered by catalog, schema, table name, and table types .
275277
276- This method fetches metadata about the tables that are available
277- in the specified catalog and schema .
278+ This method fetches metadata about tables available in the specified catalog
279+ and schema, or all catalogs and schemas if not specified .
278280
279281 Args:
280282 session_id: The session identifier
281283 max_rows: Maximum number of rows to fetch in a single batch
282284 max_bytes: Maximum number of bytes to fetch in a single batch
283285 cursor: The cursor object that will handle the results
284- catalog_name: Optional catalog name to filter tables
285- schema_name: Optional schema name to filter tables
286- table_name: Optional table pattern to filter tables by name
287- table_types: Optional list of table types to include (e.g., " TABLE", " VIEW" )
286+ catalog_name: Optional catalog name pattern to filter by
287+ schema_name: Optional schema name pattern to filter by
288+ table_name: Optional table name pattern to filter by
289+ table_types: Optional list of table types to filter by (e.g., [' TABLE', ' VIEW'] )
288290
289291 Returns:
290292 ExecuteResponse: An object containing the table metadata
@@ -301,27 +303,27 @@ def get_columns(
301303 session_id : SessionId ,
302304 max_rows : int ,
303305 max_bytes : int ,
304- cursor : Cursor ,
306+ cursor : " Cursor" ,
305307 catalog_name : Optional [str ] = None ,
306308 schema_name : Optional [str ] = None ,
307309 table_name : Optional [str ] = None ,
308310 column_name : Optional [str ] = None ,
309311 ) -> ExecuteResponse :
310312 """
311- Retrieves column metadata for tables .
313+ Retrieves a list of columns, optionally filtered by catalog, schema, table, and column name patterns .
312314
313- This method fetches metadata about the columns in the specified
314- catalog, schema, and table .
315+ This method fetches metadata about columns available in the specified table,
316+ or all tables if not specified .
315317
316318 Args:
317319 session_id: The session identifier
318320 max_rows: Maximum number of rows to fetch in a single batch
319321 max_bytes: Maximum number of bytes to fetch in a single batch
320322 cursor: The cursor object that will handle the results
321- catalog_name: Optional catalog name to filter columns
322- schema_name: Optional schema name to filter columns
323- table_name: Optional table name to filter columns
324- column_name: Optional column pattern to filter columns by name
323+ catalog_name: Optional catalog name pattern to filter by
324+ schema_name: Optional schema name pattern to filter by
325+ table_name: Optional table name pattern to filter by
326+ column_name: Optional column name pattern to filter by
325327
326328 Returns:
327329 ExecuteResponse: An object containing the column metadata
@@ -332,68 +334,24 @@ def get_columns(
332334 """
333335 pass
334336
335- # == Utility Methods ==
336- @abstractmethod
337- def handle_to_id (self , session_id : SessionId ) -> Any :
338- """
339- Gets the raw session ID from a SessionId object.
340-
341- This method extracts the underlying protocol-specific identifier
342- from the SessionId abstraction.
343-
344- Args:
345- session_id: The session identifier
346-
347- Returns:
348- The raw session ID as used by the underlying protocol
349-
350- Raises:
351- ValueError: If the session ID is not valid for this client's backend type
352- """
353- pass
354-
355- @abstractmethod
356- def handle_to_hex_id (self , session_id : SessionId ) -> str :
357- """
358- Gets a hexadecimal string representation of a session ID.
359-
360- This method converts the session ID to a human-readable hexadecimal string
361- that can be used for logging and debugging.
362-
363- Args:
364- session_id: The session identifier
365-
366- Returns:
367- str: A hexadecimal string representation of the session ID
368-
369- Raises:
370- ValueError: If the session ID is not valid for this client's backend type
371- """
372- pass
373-
374- # Properties related to specific backend features
337+ # == Properties ==
375338 @property
376339 @abstractmethod
377340 def staging_allowed_local_path (self ) -> Union [None , str , List [str ]]:
378341 """
379- Gets the local path(s) allowed for staging data.
380-
381- This property returns the path or paths on the local filesystem that
382- are allowed to be used for staging data when uploading to the server.
342+ Gets the allowed local paths for staging operations.
383343
384344 Returns:
385- Union[None, str, List[str]]: The allowed local path(s) or None if staging is not allowed
345+ Union[None, str, List[str]]: The allowed local paths for staging operations,
346+ or None if staging is not allowed
386347 """
387348 pass
388349
389350 @property
390351 @abstractmethod
391352 def ssl_options (self ) -> SSLOptions :
392353 """
393- Gets the SSL options used by this client.
394-
395- This property returns the SSL configuration options that are used
396- for secure communication with the server.
354+ Gets the SSL options for this client.
397355
398356 Returns:
399357 SSLOptions: The SSL configuration options
@@ -404,10 +362,7 @@ def ssl_options(self) -> SSLOptions:
404362 @abstractmethod
405363 def max_download_threads (self ) -> int :
406364 """
407- Gets the maximum number of threads for handling cloud fetch downloads.
408-
409- This property returns the maximum number of concurrent threads that
410- can be used for downloading result data when using cloud fetch.
365+ Gets the maximum number of download threads for cloud fetch operations.
411366
412367 Returns:
413368 int: The maximum number of download threads
0 commit comments