Skip to content

Commit e7be76b

Browse files
introduce normalised sessionId and CommandId for (near) complete backend abstraction
status is still aligned with Thrift Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent aa8af45 commit e7be76b

File tree

6 files changed

+409
-140
lines changed

6 files changed

+409
-140
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Dict, Tuple, List, Optional, Any, Union
33

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

@@ -20,19 +21,19 @@ def open_session(
2021
session_configuration: Optional[Dict[str, Any]],
2122
catalog: Optional[str],
2223
schema: Optional[str],
23-
) -> ttypes.TOpenSessionResp:
24+
) -> SessionId:
2425
pass
2526

2627
@abstractmethod
27-
def close_session(self, session_handle: ttypes.TSessionHandle) -> None:
28+
def close_session(self, session_id: SessionId) -> None:
2829
pass
2930

3031
# == Query Execution, Command Management ==
3132
@abstractmethod
3233
def execute_command(
3334
self,
3435
operation: str,
35-
session_handle: ttypes.TSessionHandle,
36+
session_id: SessionId,
3637
max_rows: int,
3738
max_bytes: int,
3839
lz4_compression: bool,
@@ -45,25 +46,21 @@ def execute_command(
4546
pass
4647

4748
@abstractmethod
48-
def cancel_command(self, operation_handle: ttypes.TOperationHandle) -> None:
49+
def cancel_command(self, command_id: CommandId) -> None:
4950
pass
5051

5152
@abstractmethod
52-
def close_command(
53-
self, operation_handle: ttypes.TOperationHandle
54-
) -> ttypes.TStatus:
53+
def close_command(self, command_id: CommandId) -> ttypes.TStatus:
5554
pass
5655

5756
@abstractmethod
58-
def get_query_state(
59-
self, operation_handle: ttypes.TOperationHandle
60-
) -> ttypes.TOperationState:
57+
def get_query_state(self, command_id: CommandId) -> ttypes.TOperationState:
6158
pass
6259

6360
@abstractmethod
6461
def get_execution_result(
6562
self,
66-
operation_handle: ttypes.TOperationHandle,
63+
command_id: CommandId,
6764
cursor: Any,
6865
) -> ExecuteResponse:
6966
pass
@@ -72,7 +69,7 @@ def get_execution_result(
7269
@abstractmethod
7370
def get_catalogs(
7471
self,
75-
session_handle: ttypes.TSessionHandle,
72+
session_id: SessionId,
7673
max_rows: int,
7774
max_bytes: int,
7875
cursor: Any,
@@ -82,7 +79,7 @@ def get_catalogs(
8279
@abstractmethod
8380
def get_schemas(
8481
self,
85-
session_handle: ttypes.TSessionHandle,
82+
session_id: SessionId,
8683
max_rows: int,
8784
max_bytes: int,
8885
cursor: Any,
@@ -94,7 +91,7 @@ def get_schemas(
9491
@abstractmethod
9592
def get_tables(
9693
self,
97-
session_handle: ttypes.TSessionHandle,
94+
session_id: SessionId,
9895
max_rows: int,
9996
max_bytes: int,
10097
cursor: Any,
@@ -108,7 +105,7 @@ def get_tables(
108105
@abstractmethod
109106
def get_columns(
110107
self,
111-
session_handle: ttypes.TSessionHandle,
108+
session_id: SessionId,
112109
max_rows: int,
113110
max_bytes: int,
114111
cursor: Any,
@@ -121,11 +118,11 @@ def get_columns(
121118

122119
# == Utility Methods ==
123120
@abstractmethod
124-
def handle_to_id(self, handle: ttypes.TSessionHandle) -> bytes:
121+
def handle_to_id(self, session_id: SessionId) -> Any:
125122
pass
126123

127124
@abstractmethod
128-
def handle_to_hex_id(self, handle: ttypes.TSessionHandle) -> str:
125+
def handle_to_hex_id(self, session_id: SessionId) -> str:
129126
pass
130127

131128
# Properties related to specific backend features

0 commit comments

Comments
 (0)