Skip to content

Commit 73fb141

Browse files
rename info to properties
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent e07f56c commit 73fb141

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import time
66
import uuid
77
import threading
8-
from typing import List, Union, Any, TYPE_CHECKING
9-
10-
if TYPE_CHECKING:
11-
from databricks.sql.client import Cursor
8+
from typing import List, Union, Any
129

10+
from databricks.sql.client import Cursor
1311
from databricks.sql.thrift_api.TCLIService.ttypes import TOperationState
1412
from databricks.sql.backend.types import (
1513
SessionId,
@@ -586,12 +584,12 @@ def open_session(self, session_configuration, catalog, schema) -> SessionId:
586584
response = self.make_request(self._client.OpenSession, open_session_req)
587585
self._check_initial_namespace(catalog, schema, response)
588586
self._check_protocol_version(response)
589-
info = (
587+
properties = (
590588
{"serverProtocolVersion": response.serverProtocolVersion}
591589
if response.serverProtocolVersion
592590
else {}
593591
)
594-
return SessionId.from_thrift_handle(response.sessionHandle, info)
592+
return SessionId.from_thrift_handle(response.sessionHandle, properties)
595593
except:
596594
self._transport.close()
597595
raise
@@ -815,7 +813,7 @@ def _results_message_to_execute_response(self, resp, operation_state):
815813
arrow_schema_bytes=schema_bytes,
816814
)
817815

818-
def get_execution_result(self, command_id: CommandId, cursor: "Cursor"):
816+
def get_execution_result(self, command_id: CommandId, cursor):
819817
thrift_handle = command_id.to_thrift_handle()
820818
if not thrift_handle:
821819
raise ValueError("Not a valid Thrift command ID")
@@ -931,7 +929,7 @@ def execute_command(
931929
max_rows: int,
932930
max_bytes: int,
933931
lz4_compression: bool,
934-
cursor: "Cursor",
932+
cursor: Cursor,
935933
use_cloud_fetch=True,
936934
parameters=[],
937935
async_op=False,
@@ -989,7 +987,7 @@ def get_catalogs(
989987
session_id: SessionId,
990988
max_rows: int,
991989
max_bytes: int,
992-
cursor: "Cursor",
990+
cursor: Cursor,
993991
) -> ExecuteResponse:
994992
thrift_handle = session_id.to_thrift_handle()
995993
if not thrift_handle:
@@ -1009,7 +1007,7 @@ def get_schemas(
10091007
session_id: SessionId,
10101008
max_rows: int,
10111009
max_bytes: int,
1012-
cursor: "Cursor",
1010+
cursor: Cursor,
10131011
catalog_name=None,
10141012
schema_name=None,
10151013
) -> ExecuteResponse:
@@ -1033,7 +1031,7 @@ def get_tables(
10331031
session_id: SessionId,
10341032
max_rows: int,
10351033
max_bytes: int,
1036-
cursor: "Cursor",
1034+
cursor: Cursor,
10371035
catalog_name=None,
10381036
schema_name=None,
10391037
table_name=None,
@@ -1061,7 +1059,7 @@ def get_columns(
10611059
session_id: SessionId,
10621060
max_rows: int,
10631061
max_bytes: int,
1064-
cursor: "Cursor",
1062+
cursor: Cursor,
10651063
catalog_name=None,
10661064
schema_name=None,
10671065
table_name=None,

src/databricks/sql/backend/types.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
backend_type: BackendType,
4444
guid: Any,
4545
secret: Optional[Any] = None,
46-
info: Optional[Dict[str, Any]] = None,
46+
properties: Optional[Dict[str, Any]] = None,
4747
):
4848
"""
4949
Initialize a SessionId.
@@ -57,7 +57,7 @@ def __init__(
5757
self.backend_type = backend_type
5858
self.guid = guid
5959
self.secret = secret
60-
self.info = info or {}
60+
self.properties = properties or {}
6161

6262
def __str__(self) -> str:
6363
"""
@@ -76,7 +76,7 @@ def __str__(self) -> str:
7676
return str(self.guid)
7777

7878
@classmethod
79-
def from_thrift_handle(cls, session_handle, info: Optional[Dict[str, Any]] = None):
79+
def from_thrift_handle(cls, session_handle, properties: Optional[Dict[str, Any]] = None):
8080
"""
8181
Create a SessionId from a Thrift session handle.
8282
@@ -93,15 +93,15 @@ def from_thrift_handle(cls, session_handle, info: Optional[Dict[str, Any]] = Non
9393
secret_bytes = session_handle.sessionId.secret
9494

9595
if session_handle.serverProtocolVersion is not None:
96-
if info is None:
97-
info = {}
98-
info["serverProtocolVersion"] = session_handle.serverProtocolVersion
96+
if properties is None:
97+
properties = {}
98+
properties["serverProtocolVersion"] = session_handle.serverProtocolVersion
9999

100-
return cls(BackendType.THRIFT, guid_bytes, secret_bytes, info)
100+
return cls(BackendType.THRIFT, guid_bytes, secret_bytes, properties)
101101

102102
@classmethod
103103
def from_sea_session_id(
104-
cls, session_id: str, info: Optional[Dict[str, Any]] = None
104+
cls, session_id: str, properties: Optional[Dict[str, Any]] = None
105105
):
106106
"""
107107
Create a SessionId from a SEA session ID.
@@ -112,7 +112,7 @@ def from_sea_session_id(
112112
Returns:
113113
A SessionId instance
114114
"""
115-
return cls(BackendType.SEA, session_id, info=info)
115+
return cls(BackendType.SEA, session_id, properties=properties)
116116

117117
def to_thrift_handle(self):
118118
"""
@@ -127,7 +127,7 @@ def to_thrift_handle(self):
127127
from databricks.sql.thrift_api.TCLIService import ttypes
128128

129129
handle_identifier = ttypes.THandleIdentifier(guid=self.guid, secret=self.secret)
130-
server_protocol_version = self.info.get("serverProtocolVersion")
130+
server_protocol_version = self.properties.get("serverProtocolVersion")
131131
return ttypes.TSessionHandle(
132132
sessionId=handle_identifier, serverProtocolVersion=server_protocol_version
133133
)
@@ -169,7 +169,7 @@ def get_protocol_version(self):
169169
Returns:
170170
The server protocol version or None if this is not a Thrift session ID
171171
"""
172-
return self.info.get("serverProtocolVersion")
172+
return self.properties.get("serverProtocolVersion")
173173

174174

175175
class CommandId:

tests/unit/test_parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ class TestSessionHandleChecks(object):
6464
],
6565
)
6666
def test_get_protocol_version_fallback_behavior(self, test_input, expected):
67-
info = (
67+
properties = (
6868
{"serverProtocolVersion": test_input.serverProtocolVersion}
6969
if test_input.serverProtocolVersion
7070
else {}
7171
)
72-
session_id = SessionId.from_thrift_handle(test_input.sessionHandle, info)
72+
session_id = SessionId.from_thrift_handle(test_input.sessionHandle, properties)
7373
assert Connection.get_protocol_version(session_id) == expected
7474

7575
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)