Skip to content

Commit 917b42b

Browse files
Merge remote-tracking branch 'origin/backend-interface' into fetch-interface
2 parents e4b7530 + 312b3c8 commit 917b42b

File tree

13 files changed

+617
-245
lines changed

13 files changed

+617
-245
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
from typing import Dict, Tuple, List, Optional, Any, Union
33

44
from databricks.sql.thrift_api.TCLIService import ttypes
5+
from databricks.sql.backend.types import SessionId, CommandId
56
from databricks.sql.utils import ExecuteResponse
67
from databricks.sql.types import SSLOptions
78

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

1510
class DatabricksClient(ABC):
1611
# == Connection and Session Management ==
@@ -20,19 +15,19 @@ def open_session(
2015
session_configuration: Optional[Dict[str, Any]],
2116
catalog: Optional[str],
2217
schema: Optional[str],
23-
) -> ttypes.TOpenSessionResp:
18+
) -> SessionId:
2419
pass
2520

2621
@abstractmethod
27-
def close_session(self, session_handle: ttypes.TSessionHandle) -> None:
22+
def close_session(self, session_id: SessionId) -> None:
2823
pass
2924

3025
# == Query Execution, Command Management ==
3126
@abstractmethod
3227
def execute_command(
3328
self,
3429
operation: str,
35-
session_handle: ttypes.TSessionHandle,
30+
session_id: SessionId,
3631
max_rows: int,
3732
max_bytes: int,
3833
lz4_compression: bool,
@@ -41,29 +36,25 @@ def execute_command(
4136
parameters: List[ttypes.TSparkParameter],
4237
async_op: bool,
4338
enforce_embedded_schema_correctness: bool,
44-
) -> "ResultSet": # Changed return type to ResultSet
39+
) -> Any:
4540
pass
4641

4742
@abstractmethod
48-
def cancel_command(self, operation_handle: ttypes.TOperationHandle) -> None:
43+
def cancel_command(self, command_id: CommandId) -> None:
4944
pass
5045

5146
@abstractmethod
52-
def close_command(
53-
self, operation_handle: ttypes.TOperationHandle
54-
) -> ttypes.TStatus:
47+
def close_command(self, command_id: CommandId) -> ttypes.TStatus:
5548
pass
5649

5750
@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:
6152
pass
6253

6354
@abstractmethod
6455
def get_execution_result(
6556
self,
66-
operation_handle: ttypes.TOperationHandle,
57+
command_id: CommandId,
6758
cursor: Any,
6859
) -> ExecuteResponse:
6960
pass
@@ -72,7 +63,7 @@ def get_execution_result(
7263
@abstractmethod
7364
def get_catalogs(
7465
self,
75-
session_handle: ttypes.TSessionHandle,
66+
session_id: SessionId,
7667
max_rows: int,
7768
max_bytes: int,
7869
cursor: Any,
@@ -82,7 +73,7 @@ def get_catalogs(
8273
@abstractmethod
8374
def get_schemas(
8475
self,
85-
session_handle: ttypes.TSessionHandle,
76+
session_id: SessionId,
8677
max_rows: int,
8778
max_bytes: int,
8879
cursor: Any,
@@ -94,7 +85,7 @@ def get_schemas(
9485
@abstractmethod
9586
def get_tables(
9687
self,
97-
session_handle: ttypes.TSessionHandle,
88+
session_id: SessionId,
9889
max_rows: int,
9990
max_bytes: int,
10091
cursor: Any,
@@ -108,7 +99,7 @@ def get_tables(
10899
@abstractmethod
109100
def get_columns(
110101
self,
111-
session_handle: ttypes.TSessionHandle,
102+
session_id: SessionId,
112103
max_rows: int,
113104
max_bytes: int,
114105
cursor: Any,
@@ -121,11 +112,11 @@ def get_columns(
121112

122113
# == Utility Methods ==
123114
@abstractmethod
124-
def handle_to_id(self, handle: ttypes.TSessionHandle) -> bytes:
115+
def handle_to_id(self, session_id: SessionId) -> Any:
125116
pass
126117

127118
@abstractmethod
128-
def handle_to_hex_id(self, handle: ttypes.TSessionHandle) -> str:
119+
def handle_to_hex_id(self, session_id: SessionId) -> str:
129120
pass
130121

131122
# Properties related to specific backend features

0 commit comments

Comments
 (0)