Przeglądaj źródła

HUE-9099 [frontend] Add parser support for Hive DROP MATERIALIZED VIEW

Johan Ahlen 6 lat temu
rodzic
commit
aa9158d220

+ 29 - 2
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_drop.jison

@@ -39,6 +39,7 @@ DropStatement
  | DropTableStatement
  | DropIndexStatement
  | DropMacroStatement
+ | DropMaterializedViewStatement
  | DropViewStatement
  | TruncateTableStatement
  ;
@@ -49,11 +50,12 @@ DropStatement_EDIT
  | DropTableStatement_EDIT
  | DropIndexStatement_EDIT
  | DropMacroStatement_EDIT
+ | DropMaterializedViewStatement_EDIT
  | DropViewStatement_EDIT
  | TruncateTableStatement_EDIT
  | 'DROP' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
+     parser.suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'MATERIALIZED VIEW', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
    }
  ;
 
@@ -158,7 +160,6 @@ OptionalPurge
  | 'PURGE'
  ;
 
-
 DropIndexStatement
  : 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier
    {
@@ -202,6 +203,32 @@ DropMacroStatement_EDIT
  | 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists_EDIT
  ;
 
+
+DropMaterializedViewStatement
+ : 'DROP' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier
+   {
+     parser.addTablePrimary($4);
+   }
+ ;
+
+DropMaterializedViewStatement_EDIT
+ : 'DROP' 'MATERIALIZED' 'CURSOR'
+   {
+     parser.suggestKeywords(['VIEW']);
+   }
+ | 'DROP' 'MATERIALIZED' 'VIEW' 'CURSOR'
+   {
+     parser.suggestTables({ onlyViews: true });
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'DROP' 'MATERIALIZED' VIEW SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ ;
+
 DropViewStatement
  : 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
    {

Plik diff jest za duży
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


Plik diff jest za duży
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 52 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Drop.test.js

@@ -66,6 +66,7 @@ describe('hiveAutocompleteParser.js DROP statements', () => {
           'DATABASE',
           'FUNCTION',
           'INDEX',
+          'MATERIALIZED VIEW',
           'ROLE',
           'SCHEMA',
           'TABLE',
@@ -351,6 +352,57 @@ describe('hiveAutocompleteParser.js DROP statements', () => {
     });
   });
 
+  describe('DROP MATERIALIZED VIEW', () => {
+    it('should handle "DROP MATERIALIZED VIEW foo.boo;|', () => {
+      assertAutoComplete({
+        beforeCursor: 'DROP MATERIALIZED VIEW foo.boo;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "DROP MATERIALIZED |', () => {
+      assertAutoComplete({
+        beforeCursor: 'DROP MATERIALIZED ',
+        afterCursor: '',
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['VIEW']
+        }
+      });
+    });
+
+    it('should suggest views for "DROP MATERIALIZED VIEW |', () => {
+      assertAutoComplete({
+        beforeCursor: 'DROP MATERIALIZED VIEW ',
+        afterCursor: '',
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { onlyViews: true },
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest views for "DROP MATERIALIZED VIEW boo.|', () => {
+      assertAutoComplete({
+        beforeCursor: 'DROP MATERIALIZED VIEW boo.',
+        afterCursor: '',
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { identifierChain: [{ name: 'boo' }], onlyViews: true }
+        }
+      });
+    });
+  });
+
   describe('DROP ROLE', () => {
     it('should handle "DROP ROLE boo;|"', () => {
       assertAutoComplete({

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików