소스 검색

HUE-7257 [autocomplete] Add autocompletion of SET options for Hive and Impala

Johan Ahlen 8 년 전
부모
커밋
67bb5a20f9

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 1 - 20
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -68,7 +68,6 @@ SqlStatement
  : DataDefinition
  | DataManipulation
  | QuerySpecification
- | SetSpecification
  | ExplainClause DataDefinition
  | ExplainClause DataManipulation
  | ExplainClause QuerySpecification
@@ -97,6 +96,7 @@ SqlStatement_EDIT
  | DataDefinition_EDIT
  | DataManipulation_EDIT
  | QuerySpecification_EDIT
+ | SetSpecification_EDIT
  | ExplainClause DataDefinition_EDIT
  | ExplainClause DataManipulation_EDIT
  | ExplainClause QuerySpecification_EDIT
@@ -267,25 +267,6 @@ RegularIdentifier
  | NonReservedKeyword
  ;
 
-SetSpecification
- : 'SET' SetOption '=' SetValue
- ;
-
-SetOption
- : RegularIdentifier
- | SetOption AnyDot RegularIdentifier
- ;
-
-SetValue
- : RegularIdentifier
- | SignedInteger
- | SignedInteger RegularIdentifier
- | QuotedValue
- | 'TRUE'
- | 'FALSE'
- | 'NULL'
- ;
-
 ExplainClause
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  | '<impala>EXPLAIN'

+ 21 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_set.jison

@@ -16,18 +16,39 @@
 
 DataDefinition
  : SetRoleStatement
+ | SetSpecification
  ;
 
 DataDefinition_EDIT
  : SetRoleStatement_EDIT
  | 'SET' 'CURSOR'
    {
+     parser.suggestSetOptions();
      if (parser.isHive()) {
        parser.suggestKeywords(['ROLE']);
      }
    }
  ;
 
+SetSpecification
+ : 'SET' SetOption '=' SetValue
+ ;
+
+SetOption
+ : RegularIdentifier
+ | SetOption AnyDot RegularIdentifier
+ ;
+
+SetValue
+ : RegularIdentifier
+ | SignedInteger
+ | SignedInteger RegularIdentifier
+ | QuotedValue
+ | 'TRUE'
+ | 'FALSE'
+ | 'NULL'
+ ;
+
 SetRoleStatement
  : 'SET' '<hive>ROLE' RegularIdentifier
  | 'SET' '<hive>ROLE' '<hive>ALL'

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecSet.js

@@ -85,7 +85,8 @@
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestKeywords: ['ROLE']
+            suggestKeywords: ['ROLE'],
+            suggestSetOptions: true
           }
         });
       });

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


+ 4 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlParseSupport.js

@@ -1205,6 +1205,10 @@ var SqlParseSupport = (function () {
       parser.yy.result.suggestAnalyticFunctions = true;
     };
 
+    parser.suggestSetOptions = function () {
+      parser.yy.result.suggestSetOptions = true;
+    };
+
     parser.suggestColumns = function (details) {
       if (typeof details === 'undefined') {
         details = {identifierChain: []};

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


+ 11 - 0
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter3.js

@@ -46,6 +46,7 @@ var AutocompleteResults = (function () {
     TABLE: { id: 'table', weight: 600, color: COLORS.TABLE, label: AutocompleterGlobals.i18n.category.table, detailsTemplate: 'table' },
     DATABASE: { id: 'database', weight: 500, color: COLORS.DATABASE, label: AutocompleterGlobals.i18n.category.database, detailsTemplate: 'database' },
     UDF: { id: 'udf', weight: 400, color: COLORS.UDF, label: AutocompleterGlobals.i18n.category.udf, detailsTemplate: 'udf' },
+    OPTION: { id: 'option', weight: 400, color: COLORS.UDF, label: AutocompleterGlobals.i18n.category.option, detailsTemplate: 'option' },
     HDFS: { id: 'hdfs', weight: 300, color: COLORS.HDFS, label: AutocompleterGlobals.i18n.category.hdfs, detailsTemplate: 'hdfs' },
     VIRTUAL_COLUMN: { id: 'virtualColumn', weight: 200, color: COLORS.COLUMN, label: AutocompleterGlobals.i18n.category.column, detailsTemplate: 'column' },
     COLREF_KEYWORD: { id: 'colrefKeyword', weight: 100, color: COLORS.KEYWORD, label: AutocompleterGlobals.i18n.category.keyword, detailsTemplate: 'keyword' },
@@ -305,6 +306,7 @@ var AutocompleteResults = (function () {
     self.handleIdentifiers();
     self.handleColumnAliases();
     self.handleCommonTableExpressions();
+    self.handleOptions();
     self.handleFunctions(colRefDeferred);
     self.handleDatabases(databasesDeferred);
     var tablesDeferred = self.handleTables(databasesDeferred);
@@ -492,6 +494,15 @@ var AutocompleteResults = (function () {
     }
   };
 
+  AutocompleteResults.prototype.handleOptions = function () {
+    var self = this;
+    if (self.parseResult.suggestSetOptions) {
+      var suggestions = [];
+      SqlSetOptions.suggestOptions(self.snippet.type(), suggestions, CATEGORIES.OPTION);
+      self.appendEntries(suggestions);
+    }
+  };
+
   AutocompleteResults.prototype.handleFunctions = function (colRefDeferred) {
     var self = this;
     if (self.parseResult.suggestFunctions) {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3013 - 0
desktop/core/src/desktop/static/desktop/js/sqlFunctions.js


+ 13 - 0
desktop/core/src/desktop/static/desktop/less/hue-autocomplete.less

@@ -182,4 +182,17 @@
   padding:3px;
   color: @cui-gray-700;
   font: 12px/normal @font-family-monospace;direction: ltr;
+}
+
+.fn-details {
+  max-width: 600px;
+  white-space: normal;
+  overflow-y: auto;
+  height: 100%;
+  padding: 8px;
+}
+
+.fn-sig {
+  white-space: pre;
+  font-family: monospace;
 }

+ 1 - 0
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -186,6 +186,7 @@ from metadata.conf import has_optimizer, OPTIMIZER
           sample: '${ _('Samples') }',
           table: '${ _('Tables') }',
           udf: '${ _('UDFs') }',
+          option: '${ _('Options') }',
           variable: '${ _('Variables') }'
         },
         meta: {

+ 13 - 0
desktop/core/src/desktop/templates/hue_ace_autocompleter.mako

@@ -67,6 +67,19 @@ from desktop.views import _ko
     </div>
   </script>
 
+  <script type="text/html" id="autocomplete-details-option">
+    <div class="autocompleter-details">
+      <div class="autocompleter-header" data-bind="text: value"></div>
+      <div class="autocompleter-details-contents">
+        <div class="autocompleter-details-contents-inner">
+          <div class="details-code">${ _ko('Type:') } <span data-bind="text: details.type"></span></div>
+          <div class="details-code">${ _ko('Default:') } <span data-bind="text: details.default"></span></div>
+          <div class="details-description" data-bind="text: details.description"></div>
+        </div>
+      </div>
+    </div>
+  </script>
+
   <script type="text/html" id="autocomplete-details-database">
   </script>
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.