Skip to content

Commit ace0137

Browse files
delegate protocol version to SessionId
1 parent 4c452d4 commit ace0137

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/databricks/sql/ids.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ def to_hex_id(self) -> str:
127127
else:
128128
return str(self.guid)
129129

130+
def get_protocol_version(self):
131+
"""
132+
Since the sessionHandle will sometimes have a serverProtocolVersion, it takes
133+
precedence over the serverProtocolVersion defined in the OpenSessionResponse.
134+
"""
135+
if self.backend_type != BackendType.THRIFT:
136+
return None
137+
session_handle = self.to_thrift_handle()
138+
if (
139+
session_handle
140+
and hasattr(session_handle, "serverProtocolVersion")
141+
and session_handle.serverProtocolVersion
142+
):
143+
return session_handle.serverProtocolVersion
144+
return None
145+
130146

131147
class CommandId:
132148
"""

src/databricks/sql/session.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,7 @@ def open(self):
9696

9797
@staticmethod
9898
def get_protocol_version(session_id: SessionId):
99-
"""
100-
Since the sessionHandle will sometimes have a serverProtocolVersion, it takes
101-
precedence over the serverProtocolVersion defined in the OpenSessionResponse.
102-
"""
103-
if session_id.backend_type != BackendType.THRIFT:
104-
return None
105-
session_handle = session_id.to_thrift_handle()
106-
if (
107-
session_handle
108-
and hasattr(session_handle, "serverProtocolVersion")
109-
and session_handle.serverProtocolVersion
110-
):
111-
return session_handle.serverProtocolVersion
112-
return None
99+
return session_id.get_protocol_version()
113100

114101
@staticmethod
115102
def server_parameterized_queries_enabled(protocolVersion):

0 commit comments

Comments
 (0)