Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compute] check correctly for is_compute for session_type #3510

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snippet will always have compute? And compute will have name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can potentially be undefined in the UI:

snippet.compute && snippet.compute.id ? snippet.compute : undefined

Not sure in which scenario but perhaps when loading back old saved editor documents, from before computes were introduced. I'm guessing is_compute takes care of checking it @amitsrivastava?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now made the checks safer.

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)


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