Browse Source

HUE-9099 [frontend] Add column constraints to Hive ALTER and CREATE statements

Johan Ahlen 6 years ago
parent
commit
292e6be694

+ 6 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/sql.jisonlex

@@ -105,6 +105,7 @@
 'OUTER'                              { return 'OUTER'; }
 'OUTER'                              { return 'OUTER'; }
 'PARTITION'                          { return 'PARTITION'; }
 'PARTITION'                          { return 'PARTITION'; }
 'PRECEDING'                          { return 'PRECEDING'; }
 'PRECEDING'                          { return 'PRECEDING'; }
+'PRECISION'                          { return 'PRECISION'; }
 'PRIMARY'                            { return 'PRIMARY'; }
 'PRIMARY'                            { return 'PRIMARY'; }
 'PURGE'                              { return 'PURGE'; }
 'PURGE'                              { return 'PURGE'; }
 'RANGE'                              { return 'RANGE'; }
 'RANGE'                              { return 'RANGE'; }
@@ -168,11 +169,15 @@
 'COMPACTIONS'                        { return 'COMPACTIONS'; }
 'COMPACTIONS'                        { return 'COMPACTIONS'; }
 'COMPUTE'                            { return 'COMPUTE'; }
 'COMPUTE'                            { return 'COMPUTE'; }
 'CONCATENATE'                        { return 'CONCATENATE'; }
 'CONCATENATE'                        { return 'CONCATENATE'; }
+'CURRENT_DATE'                       { return 'CURRENT_DATE'; }
+'CURRENT_TIMESTAMP'                  { return 'CURRENT_TIMESTAMP'; }
+'CURRENT_USER'                       { return 'CURRENT_USER'; }
 'DATA'                               { return 'DATA'; }
 'DATA'                               { return 'DATA'; }
 'DATABASES'                          { return 'DATABASES'; }
 'DATABASES'                          { return 'DATABASES'; }
 'DAY'                                { return 'DAY'; }
 'DAY'                                { return 'DAY'; }
 'DAYOFWEEK'                          { return 'DAYOFWEEK'; }
 'DAYOFWEEK'                          { return 'DAYOFWEEK'; }
 'DBPROPERTIES'                       { return 'DBPROPERTIES'; }
 'DBPROPERTIES'                       { return 'DBPROPERTIES'; }
+'DEFAULT'                            { return 'DEFAULT'; }
 'DEFERRED'                           { return 'DEFERRED'; }
 'DEFERRED'                           { return 'DEFERRED'; }
 'DEFINED'                            { return 'DEFINED'; }
 'DEFINED'                            { return 'DEFINED'; }
 'DELIMITED'                          { return 'DELIMITED'; }
 'DELIMITED'                          { return 'DELIMITED'; }
@@ -206,6 +211,7 @@ DOUBLE\s+PRECISION                   { return 'DOUBLE_PRECISION'; }
 'JSONFILE'                           { return 'JSONFILE'; }
 'JSONFILE'                           { return 'JSONFILE'; }
 'KEY'                                { return 'KEY'; }
 'KEY'                                { return 'KEY'; }
 'KEYS'                               { return 'KEYS'; }
 'KEYS'                               { return 'KEYS'; }
+'LITERAL'                            { return 'LITERAL'; }
 'LINES'                              { return 'LINES'; }
 'LINES'                              { return 'LINES'; }
 'LOAD'                               { parser.determineCase(yytext); return 'LOAD'; }
 'LOAD'                               { parser.determineCase(yytext); return 'LOAD'; }
 'LOCATION'                           { this.begin('hdfs'); return 'LOCATION'; }
 'LOCATION'                           { this.begin('hdfs'); return 'LOCATION'; }

+ 93 - 42
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_create.jison

@@ -56,8 +56,7 @@ CreateStatement_EDIT
  ;
  ;
 
 
 DatabaseDefinition
 DatabaseDefinition
- : 'CREATE' DatabaseOrSchema OptionalIfNotExists
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
+ : 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
    {
    {
      parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
      parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
    }
    }
@@ -327,15 +326,23 @@ ColumnSpecificationList_EDIT
  ;
  ;
 
 
 ColumnSpecification
 ColumnSpecification
- : ColumnIdentifier ColumnDataType OptionalColumnOptions
+ : ColumnIdentifier ColumnDataType OptionalColumnOptions OptionalComment
    {
    {
      $$ = $1;
      $$ = $1;
      $$.type = $2;
      $$.type = $2;
      var keywords = [];
      var keywords = [];
-     if (!$3['comment']) {
-       keywords.push('COMMENT');
-       if ($2.toLowerCase() === 'double') {
-         keywords.push({ value: 'PRECISION', weight: 2 });
+     if (!$4) {
+       keywords = keywords.concat([
+         { value: 'COMMENT', weight: 1 },
+         { value: 'PRIMARY KEY', weight: 2 },
+         { value: 'UNIQUE', weight: 2 },
+         { value: 'NOT NULL', weight: 2 },
+         { value: 'DEFAULT', weight: 2 }
+       ]);
+       if (!$3 && $2.toLowerCase() === 'double') {
+         keywords.push({ value: 'PRECISION', weight: 3 });
+       } else if ($3 && $3.suggestKeywords) {
+         keywords = keywords.concat($3.suggestKeywords)
        }
        }
      }
      }
      if (keywords.length > 0) {
      if (keywords.length > 0) {
@@ -345,32 +352,87 @@ ColumnSpecification
  ;
  ;
 
 
 ColumnSpecification_EDIT
 ColumnSpecification_EDIT
- : ColumnIdentifier 'CURSOR' OptionalColumnOptions
+ : ColumnIdentifier 'CURSOR' OptionalColumnOptions OptionalComment
    {
    {
      parser.suggestKeywords(parser.getColumnDataTypeKeywords());
      parser.suggestKeywords(parser.getColumnDataTypeKeywords());
    }
    }
- | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
+ | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions OptionalComment
  ;
  ;
 
 
 OptionalColumnOptions
 OptionalColumnOptions
- :                      -> {}
+ :
  | ColumnOptions
  | ColumnOptions
  ;
  ;
 
 
 ColumnOptions
 ColumnOptions
  : ColumnOption
  : ColumnOption
-   {
-     $$ = {};
-     $$[$1] = true;
-   }
  | ColumnOptions ColumnOption
  | ColumnOptions ColumnOption
+ ;
+
+ColumnOption
+ : 'PRIMARY' 'KEY' ColumnOptionOptionals        -> $3
+ | 'PRIMARY'                                    -> { suggestKeywords: [{ value: 'KEY', weight: 3 }] }
+ | 'UNIQUE' ColumnOptionOptionals               -> $2
+ | 'NOT' 'NULL' ColumnOptionOptionals           -> $3
+ | 'NOT'                                        -> { suggestKeywords: [{ value: 'NULL', weight: 3 }] }
+ | 'DEFAULT' DefaultValue ColumnOptionOptionals -> $3
+ | 'DEFAULT'
+   {
+     $$ = {
+       suggestKeywords: [
+         { value: 'LITERAL', weight: 3 },
+         { value: 'CURRENT_USER()', weight: 3 },
+         { value: 'CURRENT_DATE()', weight: 3 },
+         { value: 'CURRENT_TIMESTAMP()', weight: 3 },
+         { value: 'NULL', weight: 3 }
+       ]
+     }
+   }
+ ;
+
+ColumnOptionOptionals
+ : OptionalEnableOrDisable OptionalNovalidate OptionalRelyOrNorely
    {
    {
-     $1[$2] = true;
+     var keywords = [];
+     if (!$3) {
+       keywords.push({ value: 'RELY', weight: 3 });
+       keywords.push({ value: 'NORELY', weight: 3 });
+       if (!$2) {
+         keywords.push({ value: 'NOVALIDATE', weight: 3 });
+         if (!$1) {
+           keywords.push({ value: 'RELY', weight: 3 });
+           keywords.push({ value: 'NORELY', weight: 3 });
+         }
+       }
+     }
+     if (keywords.length) {
+       $$ = { suggestKeywords: keywords };
+     }
    }
    }
  ;
  ;
 
 
-ColumnOption
- : Comment                                                   -> 'comment'
+DefaultValue
+ : 'LITERAL'
+ | 'CURRENT_USER' '(' ')'
+ | 'CURRENT_DATE' '(' ')'
+ | 'CURRENT_TIMESTAMP' '(' ')'
+ | 'NULL'
+ ;
+
+OptionalEnableOrDisable
+ :
+ | 'ENABLE'
+ | 'DISABLE'
+ ;
+
+OptionalDisable
+ :
+ | 'DISABLE'
+ ;
+
+OptionalNovalidate
+ :
+ | 'NOVALIDATE'
  ;
  ;
 
 
 ColumnDataType
 ColumnDataType
@@ -545,7 +607,7 @@ ConstraintSpecification_EDIT
  | PrimaryKeySpecification_EDIT ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
  | PrimaryKeySpecification_EDIT ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
  | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
  | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
    {
    {
-     parser.suggestKeywords(['FOREIGN KEY']);
+     parser.suggestKeywords(['CHECK', 'FOREIGN KEY', 'UNIQUE']);
    }
    }
  | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
  | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
  | 'CURSOR' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
  | 'CURSOR' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
@@ -555,25 +617,23 @@ ConstraintSpecification_EDIT
  ;
  ;
 
 
 PrimaryKeySpecification
 PrimaryKeySpecification
- : PrimaryKey ParenthesizedColumnList 'DISABLE' 'NOVALIDATE'
+ : PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely
  ;
  ;
 
 
 PrimaryKeySpecification_EDIT
 PrimaryKeySpecification_EDIT
  : PrimaryKey_EDIT
  : PrimaryKey_EDIT
  | PrimaryKey ParenthesizedColumnList_EDIT
  | PrimaryKey ParenthesizedColumnList_EDIT
- | PrimaryKey ParenthesizedColumnList 'CURSOR'
+ | PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
    {
    {
-     parser.suggestKeywords(['DISABLE NOVALIDATE']);
+     parser.suggestKeywordsForOptionalsLR([$5, $4, $3], [
+        [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
+        { value: 'NOVALIDATE', weight: 2 },
+        { value: 'DISABLE', weight: 1 }]);
    }
    }
- | PrimaryKey ParenthesizedColumnList 'DISABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['NOVALIDATE']);
-   }
- | PrimaryKey ParenthesizedColumnList_EDIT 'DISABLE' 'NOVALIDATE'
  ;
  ;
 
 
 ForeignKeySpecification
 ForeignKeySpecification
- : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyNoRely
+ : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely
    {
    {
      parser.addTablePrimary($5);
      parser.addTablePrimary($5);
    }
    }
@@ -599,26 +659,17 @@ ForeignKeySpecification_EDIT
    {
    {
      parser.addTablePrimary($5);
      parser.addTablePrimary($5);
    }
    }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     parser.suggestKeywords(['DISABLE NOVALIDATE']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'CURSOR'
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
    {
    {
      parser.addTablePrimary($5);
      parser.addTablePrimary($5);
-     parser.suggestKeywords(['NOVALIDATE']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyNoRely 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     if (!$9) {
-       parser.suggestKeywords(['NORELY', 'RELY']);
-     }
+     parser.suggestKeywordsForOptionalsLR([$9, $8, $7], [
+        [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
+        { value: 'NOVALIDATE', weight: 2 },
+        { value: 'DISABLE', weight: 1 }]);
    }
    }
  ;
  ;
 
 
-OptionalRelyNoRely
+OptionalRelyOrNorely
  :
  :
  | 'RELY'
  | 'RELY'
  | 'NORELY'
  | 'NORELY'

+ 5 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_main.jison

@@ -115,10 +115,14 @@ NonReservedKeyword
  | 'COMPACTIONS'
  | 'COMPACTIONS'
  | 'COMPUTE'
  | 'COMPUTE'
  | 'CONCATENATE'
  | 'CONCATENATE'
+ | 'CURRENT_DATE'
+ | 'CURRENT_TIMESTAMP'
+ | 'CURRENT_USER'
  | 'DATA'
  | 'DATA'
  | 'DATABASES'
  | 'DATABASES'
  | 'DAY'
  | 'DAY'
  | 'DBPROPERTIES'
  | 'DBPROPERTIES'
+ | 'DEFAULT'
  | 'DEFERRED'
  | 'DEFERRED'
  | 'DEFINED'
  | 'DEFINED'
  | 'DELIMITED'
  | 'DELIMITED'
@@ -147,6 +151,7 @@ NonReservedKeyword
  | 'KEY'
  | 'KEY'
  | 'KEYS'
  | 'KEYS'
  | 'LINES'
  | 'LINES'
+ | 'LITERAL'
  | 'LOAD'
  | 'LOAD'
  | 'LOCATION'
  | 'LOCATION'
  | 'LOCKS'
  | 'LOCKS'

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 7 - 0
desktop/core/src/desktop/js/parse/sql/hive/sqlParseSupport.js

@@ -1238,6 +1238,13 @@ const initSqlParser = function(parser) {
     ]);
     ]);
   };
   };
 
 
+  parser.suggestKeywordsForOptionalsLR = function(optionals, keywords, override) {
+    const result = parser.getKeywordsForOptionalsLR(optionals, keywords, override);
+    if (result.length) {
+      parser.suggestKeywords(result);
+    }
+  };
+
   parser.getKeywordsForOptionalsLR = function(optionals, keywords, override) {
   parser.getKeywordsForOptionalsLR = function(optionals, keywords, override) {
     let result = [];
     let result = [];
 
 

+ 49 - 7
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Alter.test.js

@@ -372,7 +372,7 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });
@@ -428,7 +428,29 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['DISABLE NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'DISABLE', 'NORELY', 'RELY']
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER TABLE bar ADD CONSTRAINT boo PRIMARY KEY (id) DISABLE |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar ADD CONSTRAINT boo PRIMARY KEY (id) DISABLE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['NOVALIDATE', 'NORELY', 'RELY']
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER TABLE bar ADD CONSTRAINT boo PRIMARY KEY (id) DISABLE NOVALIDATE |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar ADD CONSTRAINT boo PRIMARY KEY (id) DISABLE NOVALIDATE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -577,7 +599,17 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT', 'AFTER', 'FIRST', 'CASCADE', 'RESTRICT']
+          suggestKeywords: [
+            'DEFAULT',
+            'NOT NULL',
+            'PRIMARY KEY',
+            'UNIQUE',
+            'COMMENT',
+            'AFTER',
+            'FIRST',
+            'CASCADE',
+            'RESTRICT'
+          ]
         }
         }
       });
       });
     });
     });
@@ -1001,7 +1033,7 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });
@@ -1057,7 +1089,17 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT', 'AFTER', 'FIRST', 'CASCADE', 'RESTRICT']
+          suggestKeywords: [
+            'DEFAULT',
+            'NOT NULL',
+            'PRIMARY KEY',
+            'UNIQUE',
+            'COMMENT',
+            'AFTER',
+            'FIRST',
+            'CASCADE',
+            'RESTRICT'
+          ]
         }
         }
       });
       });
     });
     });
@@ -1201,7 +1243,7 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });
@@ -1300,7 +1342,7 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });

+ 47 - 10
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Create.test.js

@@ -671,22 +671,37 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
       });
       });
     });
     });
 
 
-    it('should handle for "CREATE TABLE foo (id INT);|"', () => {
+    it('should handle "CREATE TABLE foo (id DOUBLE DEFAULT CURRENT_DATE() NOT NULL COMMENT \'foo\'); |"', () => {
+      assertAutoComplete({
+        beforeCursor:
+          "CREATE TABLE foo (id DOUBLE DEFAULT CURRENT_DATE() NOT NULL COMMENT 'foo'); ",
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "CREATE TABLE foo (id INT);|"', () => {
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id INT);',
         beforeCursor: 'CREATE TABLE foo (id INT);',
         afterCursor: '',
         afterCursor: '',
         containsKeywords: ['SELECT'],
         containsKeywords: ['SELECT'],
+        noErrors: true,
         expectedResult: {
         expectedResult: {
           lowerCase: false
           lowerCase: false
         }
         }
       });
       });
     });
     });
 
 
-    it('should handle for "CREATE TABLE foo (id INTEGER);|"', () => {
+    it('should handle "CREATE TABLE foo (id INTEGER);|"', () => {
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id INTEGER);',
         beforeCursor: 'CREATE TABLE foo (id INTEGER);',
         afterCursor: '',
         afterCursor: '',
         containsKeywords: ['SELECT'],
         containsKeywords: ['SELECT'],
+        noErrors: true,
         expectedResult: {
         expectedResult: {
           lowerCase: false
           lowerCase: false
         }
         }
@@ -829,7 +844,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });
@@ -862,7 +877,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['DISABLE NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'DISABLE', 'NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -873,7 +888,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -945,7 +960,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['DISABLE NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'DISABLE', 'NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -957,7 +972,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -969,7 +984,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['NOVALIDATE']
+          suggestKeywords: ['NOVALIDATE', 'NORELY', 'RELY']
         }
         }
       });
       });
     });
     });
@@ -1372,7 +1387,29 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['PRECISION', 'COMMENT']
+          suggestKeywords: ['PRECISION', 'DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
+        }
+      });
+    });
+
+    it('should suggest keywords for "CREATE TABLE foo (id DOUBLE DEFAULT |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'CREATE TABLE foo (id DOUBLE DEFAULT ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: [
+            'CURRENT_DATE()',
+            'CURRENT_TIMESTAMP()',
+            'CURRENT_USER()',
+            'LITERAL',
+            'NULL',
+            'DEFAULT',
+            'NOT NULL',
+            'PRIMARY KEY',
+            'UNIQUE',
+            'COMMENT'
+          ]
         }
         }
       });
       });
     });
     });
@@ -1506,7 +1543,7 @@ describe('hiveAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         afterCursor: '',
         expectedResult: {
         expectedResult: {
           lowerCase: false,
           lowerCase: false,
-          suggestKeywords: ['COMMENT']
+          suggestKeywords: ['DEFAULT', 'NOT NULL', 'PRIMARY KEY', 'UNIQUE', 'COMMENT']
         }
         }
       });
       });
     });
     });

+ 2 - 10
desktop/core/src/desktop/js/parse/sql/sqlParserRepository.js

@@ -20,27 +20,19 @@
  */
  */
 const AUTOCOMPLETE_MODULES = {
 const AUTOCOMPLETE_MODULES = {
   calcite: () => import(/* webpackChunkName: "calcite-parser" */ 'parse/sql/calcite/calciteAutocompleteParser'),
   calcite: () => import(/* webpackChunkName: "calcite-parser" */ 'parse/sql/calcite/calciteAutocompleteParser'),
-  druid: () => import(/* webpackChunkName: "druid-parser" */ 'parse/sql/druid/druidAutocompleteParser'),
-  elasticsearch: () => import(/* webpackChunkName: "elasticsearch-parser" */ 'parse/sql/elasticsearch/elasticsearchAutocompleteParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkAutocompleteParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkAutocompleteParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericAutocompleteParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericAutocompleteParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveAutocompleteParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveAutocompleteParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaAutocompleteParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaAutocompleteParser'),
-  ksql: () => import(/* webpackChunkName: "ksql-parser" */ 'parse/sql/ksql/ksqlAutocompleteParser'),
-  phoenix: () => import(/* webpackChunkName: "phoenix-parser" */ 'parse/sql/phoenix/phoenixAutocompleteParser'),
-  presto: () => import(/* webpackChunkName: "presto-parser" */ 'parse/sql/presto/prestoAutocompleteParser')
+  ksql: () => import(/* webpackChunkName: "ksql-parser" */ 'parse/sql/ksql/ksqlAutocompleteParser')
 };
 };
 const SYNTAX_MODULES = {
 const SYNTAX_MODULES = {
   calcite: () => import(/* webpackChunkName: "calcite-parser" */ 'parse/sql/calcite/calciteSyntaxParser'),
   calcite: () => import(/* webpackChunkName: "calcite-parser" */ 'parse/sql/calcite/calciteSyntaxParser'),
-  druid: () => import(/* webpackChunkName: "druid-parser" */ 'parse/sql/druid/druidSyntaxParser'),
-  elasticsearch: () => import(/* webpackChunkName: "elasticsearch-parser" */ 'parse/sql/elasticsearch/elasticsearchSyntaxParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkSyntaxParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkSyntaxParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericSyntaxParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericSyntaxParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveSyntaxParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveSyntaxParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaSyntaxParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaSyntaxParser'),
-  ksql: () => import(/* webpackChunkName: "ksql-parser" */ 'parse/sql/ksql/ksqlSyntaxParser'),
-  phoenix: () => import(/* webpackChunkName: "phoenix-parser" */ 'parse/sql/phoenix/phoenixSyntaxParser'),
-  presto: () => import(/* webpackChunkName: "presto-parser" */ 'parse/sql/presto/prestoSyntaxParser')
+  ksql: () => import(/* webpackChunkName: "ksql-parser" */ 'parse/sql/ksql/ksqlSyntaxParser')
 };
 };
 /* eslint-enable */
 /* eslint-enable */
 
 

Some files were not shown because too many files changed in this diff