|
|
@@ -362,15 +362,18 @@ def upload_query(request):
|
|
|
query_id = request.POST.get('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:
|
|
|
response['query_upload'] = _('Skipped')
|
|
|
response['status'] = 0
|