Browse Source

HUE-6835 [autocomplete] Improve completion around ALTER TABLE

- Add 'IF NOT EXISTS'
- Suggest databases after 'RENAME TO'
Johan Ahlen 8 years ago
parent
commit
519cbd8

+ 11 - 7
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_alter.jison

@@ -98,14 +98,14 @@ AlterTable_EDIT
  | AlterTableLeftSide_EDIT PartitionSpec OptionalPartitionOperations
  | AlterTableLeftSide AnyAdd OptionalIfNotExists 'CURSOR'
    {
-     if (parser.isHive()) {
-       if (!$3) {
-         parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 3 }, { value: 'COLUMNS', weight: 2 }, { value: 'PARTITION', weight: 1 }]);
-       } else {
-         parser.suggestKeywords(['PARTITION']);
-       }
+     if (!$3 && parser.isImpala()) {
+       parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 4 }, { value: 'COLUMNS', weight: 3 }, { value: 'PARTITION', weight: 2 }, { value: 'RANGE PARTITION', weight: 1 }]);
+     } else if (!$3 && parser.isHive()) {
+       parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 3 }, { value: 'COLUMNS', weight: 2 }, { value: 'PARTITION', weight: 1 }]);
      } else if (parser.isImpala()) {
-       parser.suggestKeywords([{ value: 'COLUMNS', weight: 2 }, { value: 'PARTITION', weight: 1 }]);
+       parser.suggestKeywords([{ value: 'PARTITION', weight: 2 }, { value: 'RANGE PARTITION', weight: 1 }]);
+     } else if (parser.isHive()) {
+       parser.suggestKeywords(['PARTITION']);
      }
    }
  | AlterTableLeftSide AnyReplace 'CURSOR'
@@ -183,6 +183,10 @@ AlterTable_EDIT
    {
      parser.suggestKeywords(['TO']);
    }
+ | AlterTableLeftSide AnyRename 'TO' 'CURSOR'
+   {
+     parser.suggestDatabases({ appendDot: true });
+   }
  ;
 
 HiveSpecificOperations

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


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

@@ -1315,6 +1315,18 @@
       });
 
       describe('Impala specific', function () {
+        it('should suggest databases for "ALTER TABLE db.tbl RENAME TO |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER TABLE db.tbl RENAME TO  ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestDatabases: { appendDot: true }
+            }
+          });
+        });
+
         it('should handle "alter table d2.mobile rename to d3.mobile;|"', function() {
           assertAutoComplete({
             beforeCursor: 'alter table d2.mobile rename to d3.mobile;',
@@ -1382,7 +1394,7 @@
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestKeywords: ['COLUMNS', 'PARTITION']
+              suggestKeywords: ['IF NOT EXISTS', 'COLUMNS', 'PARTITION', 'RANGE PARTITION']
             }
           });
         });

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