浏览代码

HUE-4588 [editor] The new autocompleter should support SET

No completions in this one, the intention is to prevent errors autocompleting subsequent statements. It can be extended to suggest options later.
Johan Ahlen 10 年之前
父节点
当前提交
704ac40e35

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

@@ -64,6 +64,10 @@ SelectList_ERROR_EDIT
    }
    }
  ;
  ;
 
 
+SetSpecification
+ : 'SET' SetOption '=' error
+ ;
+
 ErrorList
 ErrorList
  : error
  : error
  | Errors ',' error
  | Errors ',' error

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

@@ -178,6 +178,7 @@ SqlStatements
  | DataDefinition
  | DataDefinition
  | DataManipulation
  | DataManipulation
  | QuerySpecification
  | QuerySpecification
+ | SetSpecification
  | ExplainClause DataDefinition
  | ExplainClause DataDefinition
  | ExplainClause DataManipulation
  | ExplainClause DataManipulation
  | ExplainClause QuerySpecification
  | ExplainClause QuerySpecification
@@ -222,6 +223,25 @@ SqlStatement_EDIT
  | ExplainClause_EDIT QuerySpecification
  | ExplainClause_EDIT QuerySpecification
  ;
  ;
 
 
+SetSpecification
+ : 'SET' SetOption '=' SetValue
+ ;
+
+SetOption
+ : RegularIdentifier
+ | SetOption AnyDot RegularIdentifier
+ ;
+
+SetValue
+ : RegularIdentifier
+ | SignedInteger
+ | SignedInteger RegularIdentifier
+ | QuotedValue
+ | 'TRUE'
+ | 'FALSE'
+ | 'NULL'
+ ;
+
 ExplainClause
 ExplainClause
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  | '<impala>EXPLAIN'
  | '<impala>EXPLAIN'

文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 74 - 0
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js

@@ -322,6 +322,80 @@ define([
       });
       });
     });
     });
 
 
+    describe('SET', function () {
+      it('should handle "set hive.exec.compress.output=true;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set hive.exec.compress.output=true;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set bla.bla="ble";|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set bla.bla="ble";',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set bla.bla=\'ble\';|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set bla.bla=\'ble\';',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set mem_limit=64g;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set mem_limit=64g;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set DISABLE_UNSAFE_SPILLS=true;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set DISABLE_UNSAFE_SPILLS=true;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+
+      it('should handle "set RESERVATION_REQUEST_TIMEOUT=900000;|"', function () {
+        assertAutoComplete({
+          beforeCursor: 'set RESERVATION_REQUEST_TIMEOUT=900000;',
+          afterCursor: '',
+          noErrors: true,
+          containsKeywords: ['SELECT'],
+          expectedResult: {
+            lowerCase: true
+          }
+        });
+      });
+    });
+
     describe('Impala specific', function () {
     describe('Impala specific', function () {
       it('should suggest keywords for "|"', function() {
       it('should suggest keywords for "|"', function() {
         assertAutoComplete({
         assertAutoComplete({

部分文件因为文件数量过多而无法显示