Pārlūkot izejas kodu

HUE-7395 [jb] Support opening-up a query job id query

Romain Rigaux 8 gadi atpakaļ
vecāks
revīzija
114f5e4

+ 11 - 1
apps/impala/src/impala/server.py

@@ -184,7 +184,17 @@ class ImpalaDaemonApi(object):
       raise ImpalaDaemonApiException('ImpalaDaemonApi did not return valid JSON: %s' % e)
 
 
-  def get_query(self, query_id): pass
+  def get_query(self, query_id):
+    params = {
+      'query_id': query_id,
+      'json': 'true'
+    }
+
+    resp = self._root.get('query_plan', params=params)
+    try:
+      return json.loads(resp)
+    except ValueError, e:
+      raise ImpalaDaemonApiException('ImpalaDaemonApi did not return valid JSON: %s' % e)
 
 
   def get_query_profile(self, query_id):

+ 8 - 8
apps/jobbrowser/src/jobbrowser/apis/query_api.py

@@ -69,21 +69,21 @@ class QueryApi(Api):
   def app(self, appid):
     api = get_impalad_api(user=self.user, url=self.server_url)
 
-    job = api.get_query(query_id=appid) # TODO
+    query = api.get_query(query_id=appid)
 
     common = {
-        'id': job['jobId'],
-        'name': job['jobId'],
-        'status': job['status'],
-        'apiStatus': self._api_status(job['status']),
+        'id': appid,
+        'name': query['stmt'][:100] + ('...' if len(query['stmt']) > 100 else ''),
+        'status': query['status'],
+        'apiStatus': self._api_status(query['status']),
         'progress': 50,
         'duration': 10 * 3600,
-        'submitted': job['creationDate'],
-        'type': 'dataeng-job-%s' % job['jobType'],
+        'submitted': 0,
+        'type': 'NA',
     }
 
     common['properties'] = {
-      'properties': job
+      'properties': query
     }
 
     return common

+ 3 - 0
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -1839,6 +1839,9 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         else if (/[a-z0-9]{8}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{12}/.test(self.id())) {
           interface = 'dataeng-jobs';
         }
+        else if (/[a-z0-9]{16}:[a-z0-9]{16}/.test(self.id())) {
+          interface = 'queries';
+        }
         else if (/livy-[0-9]+/.test(self.id())) {
           interface = 'livy-sessions';
         }

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -418,7 +418,7 @@ class HS2Api(Api):
       query_id = "%x:%x" % struct.unpack(b"QQ", snippet['result']['handle']['guid'])
       jobs = [{
         'name': query_id,
-        'url': '/hue/jobbrowser/api/job#id=%s' % query_id,
+        'url': '/hue/jobbrowser#!id=%s' % query_id,
         'started': True,
         'finished': False
       }]