Bläddra i källkod

HUE-7940 [dashboard] Initial support for queries in the right assistant panel

Johan Ahlen 7 år sedan
förälder
incheckning
204dc48

+ 6 - 2
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -1581,13 +1581,17 @@ var ApiHelper = (function () {
     var self = this;
     var deferred = $.Deferred();
 
+    var isQuery = options.sourceType.indexOf('-query') !== -1;
+    var sourceType = isQuery ? options.sourceType.replace('-query', '') : options.sourceType;
+
     var request = $.ajax({
       type: 'POST',
-      url: AUTOCOMPLETE_API_PREFIX + options.path.join('/'),
+      url: AUTOCOMPLETE_API_PREFIX + (isQuery ? options.path.slice(1) : options.path).join('/'),
       data: {
         notebook: {},
         snippet: ko.mapping.toJSON({
-          type: options.sourceType
+          type: sourceType,
+          source: isQuery ? 'query' : 'data'
         })
       },
       timeout: options.timeout

+ 5 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -2931,14 +2931,16 @@ from desktop.views import _ko
 
           var fakeParentName = collectionName.indexOf('.') > -1 ? collectionName.split('.')[0] : 'default';
 
+          var sourceType = collection.source() === 'query' ? collection.engine() + '-query' : collection.engine();
+
           DataCatalog.getEntry({
-            sourceType: collection.engine(),
-            path: [fakeParentName],
+            sourceType: sourceType,
+            path: [ fakeParentName ],
             definition: { type: 'database' }
           }).done(function (fakeDbCatalogEntry) {
             var assistFakeDb = new AssistDbEntry(fakeDbCatalogEntry, null, assistDbSource, self.filter, i18n, navigationSettings);
             DataCatalog.getEntry({
-              sourceType: collection.engine(),
+              sourceType: sourceType,
               path: [fakeParentName, collectionName.indexOf('.') > -1 ? collectionName.split('.')[1] : collectionName],
               definition: { type: 'table' }
             }).done(function (collectionCatalogEntry) {