Przeglądaj źródła

HUE-5553 [metadata] Add hook for API to check syntax

Romain Rigaux 9 lat temu
rodzic
commit
a17df92

+ 6 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1106,15 +1106,19 @@ var EditorViewModel = (function() {
       });
     };
 
-    self.queryCompatibility = function () {
+    self.queryCompatibility = function (targetPlatform) {
       logGA('compatibility');
       self.suggestion(false);
 
+      if (! targetPlatform) {
+        targetPlatform = self.type();
+      }
+
       $.post("/notebook/api/optimizer/statement/compatibility", {
         notebook: ko.mapping.toJSON(notebook.getContext()),
         snippet: ko.mapping.toJSON(self.getContext()),
         sourcePlatform: self.type(),
-        targetPlatform: 'impala'
+        targetPlatform: targetPlatform
       }, function(data) {
         if (data.status == 0) {
          self.suggestion(ko.mapping.fromJS(data.query_compatibility));

+ 13 - 5
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1580,12 +1580,15 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         <use xlink:href="#hi-warning"></use>
       </svg>
     </div>
-    <div style="margin-left: 30px; line-height:20px;vertical-align: middle;">
+    <div style="margin-left: 30px; line-height:20px; vertical-align: middle;">
       <!-- ko if: hasSuggestion -->
       <!-- ko with: suggestion() -->
-        <!-- ko if: queryError.encounteredString().length == 0 -->
+        <!-- ko if: queryError.encounteredString().length == 0 && ! parseError -->
           ${ _('The query is compatible!') } <a href="javascript:void(0)" data-bind="click: function() { $parent.type('impala') }">${ _('Execute with Impala?') }</a>
         <!-- /ko -->
+        <!-- ko if: parseError -->
+          <span data-bind="text: parseError"></span>
+        <!-- /ko -->
         <!-- ko if: queryError.encounteredString -->
           ${ _('Query is not compatible with Impala.') }
           <br>
@@ -2206,13 +2209,18 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         <!-- ko if: HAS_OPTIMIZER -->
         <li class="divider"></li>
         <li>
-          <a href="javascript:void(0)" data-bind="click: queryCompatibility" title="${ _('Get Impala compatibility hints') }">
-            <i class="fa fa-fw fa-random"></i> ${_('Check Impala compatibility')}
+          <a href="javascript:void(0)" data-bind="click: function() { queryCompatibility(); }" title="${ _('Get syntax checks') }">
+            <i class="fa fa-fw fa-check"></i> ${_('Check syntax')}
           </a>
         </li>
         <li>
           <a href="javascript:void(0)" data-bind="click: checkComplexity" title="${ _('Get recommendations on query risks and optimizations') }">
-            <i class="fa fa-fw fa-check"></i> ${_('Check complexity')}
+            <i class="fa fa-fw fa-bolt"></i> ${_('Check complexity')}
+          </a>
+        </li>
+        <li>
+          <a href="javascript:void(0)" data-bind="click: function() { queryCompatibility('impala'); }, visible: type() == 'hive'" title="${ _('Get Impala compatibility hints') }">
+            <i class="fa fa-fw fa-random"></i> ${_('Check Impala compatibility')}
           </a>
         </li>
         <li>