소스 검색

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 9 년 전
부모
커밋
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({

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