Skip to content

Commit d80a3e2

Browse files
take TOpenSessionResp in get_protocol_version to maintain existing interface
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 9b6afd2 commit d80a3e2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/databricks/sql/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from databricks.sql.backend.types import CommandId, BackendType, CommandState, SessionId
5151

5252
from databricks.sql.thrift_api.TCLIService.ttypes import (
53+
TOpenSessionResp,
5354
TSparkParameter,
5455
TOperationState,
5556
)
@@ -320,8 +321,16 @@ def protocol_version(self):
320321
return self.session.protocol_version
321322

322323
@staticmethod
323-
def get_protocol_version(session_id: SessionId):
324+
def get_protocol_version(openSessionResp: TOpenSessionResp):
324325
"""Delegate to Session class static method"""
326+
properties = (
327+
{"serverProtocolVersion": openSessionResp.serverProtocolVersion}
328+
if openSessionResp.serverProtocolVersion
329+
else {}
330+
)
331+
session_id = SessionId.from_thrift_handle(
332+
openSessionResp.sessionHandle, properties
333+
)
325334
return Session.get_protocol_version(session_id)
326335

327336
@property

tests/unit/test_parameters.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ class TestSessionHandleChecks(object):
6464
],
6565
)
6666
def test_get_protocol_version_fallback_behavior(self, test_input, expected):
67-
properties = (
68-
{"serverProtocolVersion": test_input.serverProtocolVersion}
69-
if test_input.serverProtocolVersion
70-
else {}
71-
)
72-
session_id = SessionId.from_thrift_handle(test_input.sessionHandle, properties)
73-
assert Connection.get_protocol_version(session_id) == expected
67+
assert Connection.get_protocol_version(test_input) == expected
7468

7569
@pytest.mark.parametrize(
7670
"test_input,expected",

0 commit comments

Comments
 (0)