瀏覽代碼

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

Johan Ahlen 8 年之前
父節點
當前提交
7af41ff101

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

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

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

@@ -16,10 +16,12 @@
 
 DataDefinition
  : DropStatement
+ | HiveAbortStatement
  ;
 
 DataDefinition_EDIT
  : DropStatement_EDIT
+ | HiveAbortStatement_EDIT
  ;
 
 DataManipulation
@@ -483,4 +485,20 @@ OptionalImpalaDeleteTableRef
 
 ImpalaDeleteTableRef_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
- : '<hive>ADD'
+ : '<hive>ABORT'
+ | '<hive>ADD'
  | '<hive>ADMIN'
  | '<hive>AFTER'
  | '<hive>ANALYZE'

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

@@ -423,7 +423,7 @@
           dialect: 'hive',
           expectedResult: {
             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',
               '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;
 
-    it('should suggest keywords for "|"', function() {
-      assertAutoComplete({
-        beforeCursor: '',
-        afterCursor: '',
-        containsKeywords: ['DROP'],
-        expectedResult: {
-          lowerCase: false
-        }
-      });
-    });
-
     it('should suggest keywords for "DROP |"', function() {
       assertAutoComplete({
         beforeCursor: 'DROP ',
@@ -50,6 +39,31 @@
     });
 
     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 () {
         assertAutoComplete({
           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() {
         var result = sqlSyntaxParser.parseSyntax('SLELECT ', '', 'hive');
         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()) {
-        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()) {

文件差異過大導致無法顯示
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


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