Просмотр исходного кода

HUE-6958 [autocomplete] Add support for Hive ABORT statement

Johan Ahlen 8 лет назад
Родитель
Сommit
7af41ff

+ 1 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql.jisonlex

@@ -69,6 +69,7 @@
 <hive>'VIEWS'                              { return '<hive>VIEWS'; }
 <hive>'VIEWS'                              { return '<hive>VIEWS'; }
 
 
 // Non-reserved Keywords
 // Non-reserved Keywords
+<hive>'ABORT'                              { parser.determineCase(yytext); return '<hive>ABORT'; }
 <hive>'ADD'                                { return '<hive>ADD'; }
 <hive>'ADD'                                { return '<hive>ADD'; }
 <hive>'ADMIN'                              { return '<hive>ADMIN'; }
 <hive>'ADMIN'                              { return '<hive>ADMIN'; }
 <hive>'AFTER'                              { return '<hive>AFTER'; }
 <hive>'AFTER'                              { return '<hive>AFTER'; }

+ 18 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_drop.jison

@@ -16,10 +16,12 @@
 
 
 DataDefinition
 DataDefinition
  : DropStatement
  : DropStatement
+ | HiveAbortStatement
  ;
  ;
 
 
 DataDefinition_EDIT
 DataDefinition_EDIT
  : DropStatement_EDIT
  : DropStatement_EDIT
+ | HiveAbortStatement_EDIT
  ;
  ;
 
 
 DataManipulation
 DataManipulation
@@ -483,4 +485,20 @@ OptionalImpalaDeleteTableRef
 
 
 ImpalaDeleteTableRef_EDIT
 ImpalaDeleteTableRef_EDIT
  : TableReference_EDIT
  : TableReference_EDIT
+ ;
+
+HiveAbortStatement
+ : '<hive>ABORT' '<hive>TRANSACTIONS' TransactionIdList
+ ;
+
+HiveAbortStatement_EDIT
+ : '<hive>ABORT' 'CURSOR'
+   {
+     parser.suggestKeywords(['TRANSACTIONS']);
+   }
+ ;
+
+TransactionIdList
+ : UnsignedNumericLiteral
+ | TransactionIdList ',' UnsignedNumericLiteral
  ;
  ;

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

@@ -106,7 +106,8 @@ SqlStatement_EDIT
  ;
  ;
 
 
 NonReservedKeyword
 NonReservedKeyword
- : '<hive>ADD'
+ : '<hive>ABORT'
+ | '<hive>ADD'
  | '<hive>ADMIN'
  | '<hive>ADMIN'
  | '<hive>AFTER'
  | '<hive>AFTER'
  | '<hive>ANALYZE'
  | '<hive>ANALYZE'

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

@@ -423,7 +423,7 @@
           dialect: 'hive',
           dialect: 'hive',
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
-            suggestKeywords: ['ALTER', 'ANALYZE TABLE', 'CREATE', 'DELETE', 'DESCRIBE',
+            suggestKeywords: ['ABORT', 'ALTER', 'ANALYZE TABLE', 'CREATE', 'DELETE', 'DESCRIBE',
               'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LOAD', 'MSCK',
               'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LOAD', 'MSCK',
               'RELOAD FUNCTION', 'RESET', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE', 'WITH']
               'RELOAD FUNCTION', 'RESET', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE', 'WITH']
           }
           }

+ 25 - 11
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecDrop.js

@@ -26,17 +26,6 @@
 
 
     var assertAutoComplete = SqlTestUtils.assertAutocomplete;
     var assertAutoComplete = SqlTestUtils.assertAutocomplete;
 
 
-    it('should suggest keywords for "|"', function() {
-      assertAutoComplete({
-        beforeCursor: '',
-        afterCursor: '',
-        containsKeywords: ['DROP'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
     it('should suggest keywords for "DROP |"', function() {
     it('should suggest keywords for "DROP |"', function() {
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'DROP ',
         beforeCursor: 'DROP ',
@@ -50,6 +39,31 @@
     });
     });
 
 
     describe('hive specific', function () {
     describe('hive specific', function () {
+
+      it('should suggest keywords for "|"', function() {
+        assertAutoComplete({
+          beforeCursor: '',
+          afterCursor: '',
+          dialect: 'hive',
+          containsKeywords: ['ABORT'],
+          expectedResult: {
+            lowerCase: false
+          }
+        });
+      });
+
+      it('should suggest keywords for "ABORT |"', function () {
+        assertAutoComplete({
+          beforeCursor: 'ABORT ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['TRANSACTIONS']
+          }
+        });
+      });
+
       it('should suggest keywords for "DROP |"', function () {
       it('should suggest keywords for "DROP |"', function () {
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'DROP ',
           beforeCursor: 'DROP ',

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

@@ -142,7 +142,7 @@
       it('should suggest expected words for "SLELECT "', function() {
       it('should suggest expected words for "SLELECT "', function() {
         var result = sqlSyntaxParser.parseSyntax('SLELECT ', '', 'hive');
         var result = sqlSyntaxParser.parseSyntax('SLELECT ', '', 'hive');
         expect(result).toBeTruthy();
         expect(result).toBeTruthy();
-        expect(expectedToStrings(result.expected)).toEqual(['SELECT', 'DELETE', 'SET', 'ALTER', 'INSERT', 'RELOAD', 'ANALYZE', 'CREATE', 'EXPLAIN', 'EXPORT', 'GRANT', 'IMPORT', 'LOAD', 'MSCK', 'REVOKE', 'SHOW', 'USE', 'DROP', 'FROM', 'TRUNCATE', 'UPDATE', 'WITH', 'DESCRIBE']);
+        expect(expectedToStrings(result.expected)).toEqual(['SELECT', 'DELETE', 'SET', 'ALTER', 'INSERT', 'RELOAD', 'ABORT', 'ANALYZE', 'CREATE', 'EXPLAIN', 'EXPORT', 'GRANT', 'IMPORT', 'LOAD', 'MSCK', 'REVOKE', 'SHOW', 'USE', 'DROP', 'FROM', 'TRUNCATE', 'UPDATE', 'WITH', 'DESCRIBE']);
       });
       });
     });
     });
 
 

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlParseSupport.js

@@ -1073,7 +1073,7 @@ var SqlParseSupport = (function () {
       }
       }
 
 
       if (parser.isHive()) {
       if (parser.isHive()) {
-        keywords = keywords.concat(['ANALYZE TABLE', 'DELETE', 'EXPORT', 'IMPORT', 'LOAD', 'MSCK', 'RELOAD FUNCTION', 'RESET']);
+        keywords = keywords.concat(['ABORT', 'ANALYZE TABLE', 'DELETE', 'EXPORT', 'IMPORT', 'LOAD', 'MSCK', 'RELOAD FUNCTION', 'RESET']);
       }
       }
 
 
       if (parser.isImpala()) {
       if (parser.isImpala()) {

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


Некоторые файлы не были показаны из-за большого количества измененных файлов