Browse Source

HUE-7269 [editor] Error popup when exploring table from assist and NavOpt on

This query is a task, not a end user typed query and should not be uploaded.
Romain Rigaux 8 years ago
parent
commit
1214197fea
1 changed files with 9 additions and 6 deletions
  1. 9 6
      desktop/libs/metadata/src/metadata/optimizer_api.py

+ 9 - 6
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -362,15 +362,18 @@ def upload_query(request):
   query_id = request.POST.get('query_id')
   query_id = request.POST.get('query_id')
 
 
   if OPTIMIZER.AUTO_UPLOAD_QUERIES.get() and source_platform in ('hive', 'impala') and query_id:
   if OPTIMIZER.AUTO_UPLOAD_QUERIES.get() and source_platform in ('hive', 'impala') and query_id:
-    doc = Document2.objects.document(request.user, doc_id=query_id)
+    try:
+      doc = Document2.objects.document(request.user, doc_id=query_id)
 
 
-    query_data = Notebook(document=doc).get_data()
-    queries = _convert_queries([query_data])
-    source_platform = query_data['snippets'][0]['type']
+      query_data = Notebook(document=doc).get_data()
+      queries = _convert_queries([query_data])
+      source_platform = query_data['snippets'][0]['type']
 
 
-    api = OptimizerApi(request.user)
+      api = OptimizerApi(request.user)
 
 
-    response['query_upload'] = api.upload(data=queries, data_type='queries', source_platform=source_platform)
+      response['query_upload'] = api.upload(data=queries, data_type='queries', source_platform=source_platform)
+    except Document2.DoesNotExist:
+      response['query_upload'] = _('Skipped as task query')
   else:
   else:
     response['query_upload'] = _('Skipped')
     response['query_upload'] = _('Skipped')
   response['status'] = 0
   response['status'] = 0