瀏覽代碼

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 年之前
父節點
當前提交
704ac40

+ 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
  : error
  | Errors ',' error

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

@@ -178,6 +178,7 @@ SqlStatements
  | DataDefinition
  | DataManipulation
  | QuerySpecification
+ | SetSpecification
  | ExplainClause DataDefinition
  | ExplainClause DataManipulation
  | ExplainClause QuerySpecification
@@ -222,6 +223,25 @@ SqlStatement_EDIT
  | ExplainClause_EDIT QuerySpecification
  ;
 
+SetSpecification
+ : 'SET' SetOption '=' SetValue
+ ;
+
+SetOption
+ : RegularIdentifier
+ | SetOption AnyDot RegularIdentifier
+ ;
+
+SetValue
+ : RegularIdentifier
+ | SignedInteger
+ | SignedInteger RegularIdentifier
+ | QuotedValue
+ | 'TRUE'
+ | 'FALSE'
+ | 'NULL'
+ ;
+
 ExplainClause
  : '<hive>EXPLAIN' OptionalHiveExplainTypes
  | '<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 () {
       it('should suggest keywords for "|"', function() {
         assertAutoComplete({

部分文件因文件數量過多而無法顯示