From ad854bbb703ce4af236eb390f04a41142359f38b Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Mon, 23 Oct 2023 21:27:46 -0700 Subject: [PATCH] [compute] check correctly for is_compute for session_type the problem is that when multiple queries are executed, we are not able to reuse the existing sessions as the session reuse is broken. if computes are in use then use compute[name] as the type otherwise fallback to old snippet[type] and use it everywhere. Change-Id: I0e6cb1149ca7961fc799ccce69fe70343d241bb5 --- .../libs/notebook/src/notebook/connectors/hiveserver2.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py b/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py index 0df13556ab7..4c80d4d1967 100644 --- a/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py +++ b/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py @@ -29,6 +29,7 @@ from django.urls import reverse +from beeswax.common import is_compute from desktop.auth.backend import is_admin from desktop.conf import USE_DEFAULT_CONFIGURATION, has_connectors from desktop.lib.conf import BoundConfig @@ -316,11 +317,11 @@ def execute(self, notebook, snippet): db = self._get_db(snippet, interpreter=self.interpreter) statement = self._get_current_statement(notebook, snippet) - session = self._get_session(notebook, snippet['type']) + compute = snippet.get('compute') + session_type = compute['name'] if is_compute(snippet) else snippet['type'] + session = self._get_session(notebook, session_type) query = self._prepare_hql_query(snippet, statement['statement'], session) - compute = snippet.get('compute') - session_type = compute['name'] if compute else snippet['type'] _session = self._get_session_by_id(notebook, session_type) @@ -349,7 +350,7 @@ def execute(self, notebook, snippet): 'log_context': handle.log_context, 'session_guid': handle.session_guid, 'session_id': handle.session_id, - 'session_type': snippet['type'] + 'session_type': session_type } response.update(statement)