2
2
from typing import Dict , Tuple , List , Optional , Any , Union
3
3
4
4
from databricks .sql .thrift_api .TCLIService import ttypes
5
+ from databricks .sql .backend .types import SessionId , CommandId
5
6
from databricks .sql .utils import ExecuteResponse
6
7
from databricks .sql .types import SSLOptions
7
8
8
- # Forward reference for type hints
9
- from typing import TYPE_CHECKING
10
-
11
- if TYPE_CHECKING :
12
- from databricks .sql .result_set import ResultSet
13
-
14
9
15
10
class DatabricksClient (ABC ):
16
11
# == Connection and Session Management ==
@@ -20,19 +15,19 @@ def open_session(
20
15
session_configuration : Optional [Dict [str , Any ]],
21
16
catalog : Optional [str ],
22
17
schema : Optional [str ],
23
- ) -> ttypes . TOpenSessionResp :
18
+ ) -> SessionId :
24
19
pass
25
20
26
21
@abstractmethod
27
- def close_session (self , session_handle : ttypes . TSessionHandle ) -> None :
22
+ def close_session (self , session_id : SessionId ) -> None :
28
23
pass
29
24
30
25
# == Query Execution, Command Management ==
31
26
@abstractmethod
32
27
def execute_command (
33
28
self ,
34
29
operation : str ,
35
- session_handle : ttypes . TSessionHandle ,
30
+ session_id : SessionId ,
36
31
max_rows : int ,
37
32
max_bytes : int ,
38
33
lz4_compression : bool ,
@@ -41,29 +36,25 @@ def execute_command(
41
36
parameters : List [ttypes .TSparkParameter ],
42
37
async_op : bool ,
43
38
enforce_embedded_schema_correctness : bool ,
44
- ) -> "ResultSet" : # Changed return type to ResultSet
39
+ ) -> Any :
45
40
pass
46
41
47
42
@abstractmethod
48
- def cancel_command (self , operation_handle : ttypes . TOperationHandle ) -> None :
43
+ def cancel_command (self , command_id : CommandId ) -> None :
49
44
pass
50
45
51
46
@abstractmethod
52
- def close_command (
53
- self , operation_handle : ttypes .TOperationHandle
54
- ) -> ttypes .TStatus :
47
+ def close_command (self , command_id : CommandId ) -> ttypes .TStatus :
55
48
pass
56
49
57
50
@abstractmethod
58
- def get_query_state (
59
- self , operation_handle : ttypes .TOperationHandle
60
- ) -> ttypes .TOperationState :
51
+ def get_query_state (self , command_id : CommandId ) -> ttypes .TOperationState :
61
52
pass
62
53
63
54
@abstractmethod
64
55
def get_execution_result (
65
56
self ,
66
- operation_handle : ttypes . TOperationHandle ,
57
+ command_id : CommandId ,
67
58
cursor : Any ,
68
59
) -> ExecuteResponse :
69
60
pass
@@ -72,7 +63,7 @@ def get_execution_result(
72
63
@abstractmethod
73
64
def get_catalogs (
74
65
self ,
75
- session_handle : ttypes . TSessionHandle ,
66
+ session_id : SessionId ,
76
67
max_rows : int ,
77
68
max_bytes : int ,
78
69
cursor : Any ,
@@ -82,7 +73,7 @@ def get_catalogs(
82
73
@abstractmethod
83
74
def get_schemas (
84
75
self ,
85
- session_handle : ttypes . TSessionHandle ,
76
+ session_id : SessionId ,
86
77
max_rows : int ,
87
78
max_bytes : int ,
88
79
cursor : Any ,
@@ -94,7 +85,7 @@ def get_schemas(
94
85
@abstractmethod
95
86
def get_tables (
96
87
self ,
97
- session_handle : ttypes . TSessionHandle ,
88
+ session_id : SessionId ,
98
89
max_rows : int ,
99
90
max_bytes : int ,
100
91
cursor : Any ,
@@ -108,7 +99,7 @@ def get_tables(
108
99
@abstractmethod
109
100
def get_columns (
110
101
self ,
111
- session_handle : ttypes . TSessionHandle ,
102
+ session_id : SessionId ,
112
103
max_rows : int ,
113
104
max_bytes : int ,
114
105
cursor : Any ,
@@ -121,11 +112,11 @@ def get_columns(
121
112
122
113
# == Utility Methods ==
123
114
@abstractmethod
124
- def handle_to_id (self , handle : ttypes . TSessionHandle ) -> bytes :
115
+ def handle_to_id (self , session_id : SessionId ) -> Any :
125
116
pass
126
117
127
118
@abstractmethod
128
- def handle_to_hex_id (self , handle : ttypes . TSessionHandle ) -> str :
119
+ def handle_to_hex_id (self , session_id : SessionId ) -> str :
129
120
pass
130
121
131
122
# Properties related to specific backend features
0 commit comments