Browse Source

HUE-8758 [connector] Adding connector to saved queries

Romain 5 years ago
parent
commit
7645ebbf00

+ 6 - 0
desktop/core/src/desktop/js/apps/notebook2/editorViewModel.js

@@ -62,6 +62,9 @@ class EditorViewModel {
       if (this.editorMode()) {
         const snippet = this.getActiveSnippet();
         if (snippet) {
+          if (!snippet.connector()) {
+            console.warn('Snippet connector is empty');
+          }
           return snippet.connector();
         }
       } else if (this.config() && this.config().app_config && this.config().app_config.editor) {
@@ -364,6 +367,9 @@ class EditorViewModel {
 
       if (typeof skipUrlChange === 'undefined' && !this.isNotificationManager()) {
         if (this.editorMode()) {
+          if (!this.editorType()) {
+            console.warn('Snippet connector type or dialect is empty');
+          }
           this.changeURL(
             this.URLS.editor + '?editor=' + docData.document.id + '&type=' + this.editorType()
           );

+ 5 - 2
desktop/libs/notebook/src/notebook/api.py

@@ -30,7 +30,7 @@ from django.views.decorators.http import require_GET, require_POST
 import opentracing.tracer
 
 from azure.abfs.__init__ import abfspath
-from desktop.conf import TASK_SERVER
+from desktop.conf import TASK_SERVER, ENABLE_CONNECTORS
 from desktop.lib.i18n import smart_str
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.exceptions_renderable import PopupException
@@ -216,6 +216,9 @@ def execute(request, dialect=None):
   notebook = json.loads(request.POST.get('notebook', '{}'))
   snippet = json.loads(request.POST.get('snippet', '{}'))
 
+  if dialect:
+    notebook['dialect'] = dialect
+
   with opentracing.tracer.start_span('notebook-execute') as span:
     span.set_tag('user-id', request.user.username)
 
@@ -513,7 +516,7 @@ def _clear_sessions(notebook):
 
 
 def _historify(notebook, user):
-  query_type = notebook['type']
+  query_type = 'query-%(dialect)s' % notebook if ENABLE_CONNECTORS.get() else notebook['type']
   name = notebook['name'] if (notebook['name'] and notebook['name'].strip() != '') else DEFAULT_HISTORY_NAME
   is_managed = notebook.get('isManaged') == True # Prevents None