Skip to content

Commit f97e9d3

Browse files
juliuszsompolskisusodapop
authored andcommitted
Don't use client defined session_id in open session
Don't use client defined "0xD01: optional THandleIdentifier sessionId" in TOpenSessionReq. This is not part of the public Thriftserver protocol, and was implemented to be used only within Databricks. Remove it as not part of the "public" protocol and not used at this point. There were no test of this functionality. When Databricks tried to use it, it turned out to not work. Therefore, removing.
1 parent 5226c6b commit f97e9d3

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

cmdexec/clients/python/src/databricks/sql/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def __init__(self,
5555
# verification. If not provide, uses system truststore.
5656
# _tls_client_cert_file, _tls_client_cert_key_file
5757
# Set client SSL certificate.
58-
# _session_id
59-
# Specify the session id of the connection. For Redash use only.
6058
# _retry_stop_after_attempts_count
6159
# The maximum number of attempts during a request retry sequence (defaults to 24)
6260

@@ -93,8 +91,7 @@ def __init__(self,
9391
_connection_uri=kwargs.get("_connection_uri"),
9492
_retry_stop_after_attempts_count=kwargs.get("_retry_stop_after_attempts_count", 24))
9593

96-
self._session_handle = self.thrift_backend.open_session(
97-
session_id=kwargs.get("_session_id"))
94+
self._session_handle = self.thrift_backend.open_session()
9895
self.open = True
9996
logger.info("Successfully opened session " + str(self.get_session_id()))
10097
self._cursors = [] # type: List[Cursor]

cmdexec/clients/python/src/databricks/sql/thrift_backend.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,10 @@ def _check_protocol_version(self, t_open_session_resp):
153153
"SPARK_CLI_SERVICE_PROTOCOL_V3, "
154154
"instead got: {}".format(protocol_version))
155155

156-
def open_session(self, session_id=None):
156+
def open_session(self):
157157
try:
158158
self._transport.open()
159-
handle_identifier = session_id and ttypes.THandleIdentifier(session_id, uuid4().bytes)
160159
open_session_req = ttypes.TOpenSessionReq(
161-
sessionId=handle_identifier,
162160
client_protocol_i64=ttypes.TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V4,
163161
client_protocol=None,
164162
configuration={

cmdexec/clients/python/tests/test_thrift_backend.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,6 @@ def test_get_columns_calls_client_and_handle_execute_response(self, tcli_service
609609
# Check response handling
610610
thrift_backend._handle_execute_response.assert_called_with(response, cursor_mock)
611611

612-
@patch("databricks.sql.thrift_backend.TCLIService.Client")
613-
def test_open_session_uses_user_provided_session_id(self, tcli_service_class):
614-
tcli_service_instance = tcli_service_class.return_value
615-
tcli_service_instance.OpenSession.return_value = self.open_session_resp
616-
617-
thrift_backend = ThriftBackend("foobar", 443, "path", [])
618-
thrift_backend.open_session(0b111)
619-
self.assertEqual(tcli_service_instance.OpenSession.call_args[0][0].sessionId.guid, 0b111)
620-
621612
@patch("databricks.sql.thrift_backend.TCLIService.Client")
622613
def test_open_session_user_provided_session_id_optional(self, tcli_service_class):
623614
tcli_service_instance = tcli_service_class.return_value

0 commit comments

Comments
 (0)