Skip to content

Commit

Permalink
[compute] check correctly for is_compute for session_type (#3510)
Browse files Browse the repository at this point in the history
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.

frontend update to send the session_type from the session returned
by previous call.

Change-Id: I0e6cb1149ca7961fc799ccce69fe70343d241bb5
  • Loading branch information
amitsrivastava authored Oct 24, 2023
1 parent f051be8 commit 0e8667e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions desktop/core/src/desktop/js/apps/notebook/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ class Snippet {
if (!notebook.sessions().length) {
notebook.addSession(
new Session(vm, {
type: self.type(),
type: data.handle.session_type || self.type(),
session_id: data.handle.session_guid,
id: data.handle.session_id,
properties: {}
Expand All @@ -1887,7 +1887,7 @@ class Snippet {
} else {
notebook.sessions()[0].session_id(data.handle.session_guid);
notebook.sessions()[0].id(data.handle.session_id);
notebook.sessions()[0].type(self.type());
notebook.sessions()[0].type(data.handle.session_type || self.type());
}
}
if (vm.editorMode()) {
Expand Down
9 changes: 5 additions & 4 deletions desktop/libs/notebook/src/notebook/connectors/hiveserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) and compute.get('name') 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)


Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0e8667e

Please sign in to comment.