Details
Description
In debugging the code a bit more, I found the issue related to how the LLAP editor check for existing session to use for running its query.
The file having issue is:/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py
And specifically this function:
def _get_session_by_id(self, notebook, type='hive'):
session = self._get_session(notebook, type)
if session:
session_id = session.get('id')
if session_id:
filters = {'id': session_id, 'application': 'beeswax' if type == 'hive' else type}
if not is_admin(self.user):
filters['owner'] = self.user
return Session.objects.get(**filters)
The line session = self._get_session(notebook, type), returns an active session id.
But when the execution hits line return Session.objects.get(**filters), it can't find an active session with that session_id and type llap.
There seem to be a bug in Hue where all hive sessions, HS2 and LLAP, are stored in Session object under type beeswax. That is why when looking for that session_id and type llap it can't find it.
And it throws the exception below.
Traceback (most recent call last):
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/decorators.py", line 114, in wrapper
return f(*args, **kwargs)
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/api.py", line 222, in execute
response = _execute_notebook(request, notebook, snippet)
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/api.py", line 153, in _execute_notebook
response['handle'] = interpreter.execute(notebook, snippet)
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py", line 98, in decorator
return func(*args, **kwargs)
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py", line 294, in execute
_session = self._get_session_by_id(notebook, snippet['type'])
File "/usr/hdp/current/hue/desktop/libs/notebook/src/notebook/connectors/hiveserver2.py", line 675, in _get_session_by_id
ss = Session.objects.get(**filters)
File "/usr/hdp/current/hue/build/env/lib/python2.7/site-packages/Django-1.11.29-py2.7.egg/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/hdp/current/hue/build/env/lib/python2.7/site-packages/Django-1.11.29-py2.7.egg/django/db/models/query.py", line 380, in get
self.model._meta.object_name
DoesNotExist: Session matching query does not exist.
In order to make it work, I had to change the line filters = {'id': session_id, 'application': 'beeswax' if type == 'hive' else type} to filters = {'id': session_id, 'application': 'beeswax' if type == 'hive' or type == 'llap' else type}