소스 검색

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

Johan Ahlen 6 년 전
부모
커밋
4590099e79

+ 38 - 1
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_alter.jison

@@ -25,6 +25,7 @@ DataDefinition_EDIT
 AlterStatement
  : AlterDatabase
  | AlterIndex
+ | AlterMaterializedView
  | AlterTable
  | AlterView
  | Msck
@@ -34,13 +35,14 @@ AlterStatement
 AlterStatement_EDIT
  : AlterDatabase_EDIT
  | AlterIndex_EDIT
+ | AlterMaterializedView_EDIT
  | AlterTable_EDIT
  | AlterView_EDIT
  | Msck_EDIT
  | ReloadFunction_EDIT
  | 'ALTER' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'INDEX', 'SCHEMA', 'TABLE', 'VIEW']);
+     parser.suggestKeywords(['DATABASE', 'INDEX', 'MATERIALIZED VIEW', 'SCHEMA', 'TABLE', 'VIEW']);
    }
  ;
 
@@ -122,6 +124,41 @@ AlterIndex_EDIT
    }
  ;
 
+AlterMaterializedView
+ : 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier EnableOrDisable 'REWRITE'
+   {
+     parser.addTablePrimary($4);
+   }
+ ;
+
+AlterMaterializedView_EDIT
+ : 'ALTER' 'MATERIALIZED' 'CURSOR'
+   {
+     parser.suggestKeywords(['VIEW']);
+   }
+ | 'ALTER' 'MATERIALIZED' 'VIEW' 'CURSOR'
+   {
+     parser.suggestTables({ onlyViews: true });
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ | 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier 'CURSOR'
+   {
+     parser.addTablePrimary($4);
+     parser.suggestKeywords(['DISABLE REWRITE', 'ENABLE REWRITE']);
+   }
+ | 'ALTER' 'MATERIALIZED' 'VIEW' SchemaQualifiedTableIdentifier EnableOrDisable 'CURSOR'
+   {
+     parser.addTablePrimary($4);
+     parser.suggestKeywords(['REWRITE']);
+   }
+ ;
+
 AlterTable
  : AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 81 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Alter.test.js

@@ -220,6 +220,87 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
     });
   });
 
+  describe('ALTER MATERIALIZED VIEW', () => {
+    it('should handle "ALTER MATERIALIZED VIEW baa.boo ENABLE REWRITE;|"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED VIEW baa.boo ENABLE REWRITE;;',
+        afterCursor: '',
+        noErrors: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER ',
+        afterCursor: '',
+        containsKeywords: ['MATERIALIZED VIEW'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER MATERIALIZED |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['VIEW']
+        }
+      });
+    });
+
+    it('should suggest views for "ALTER MATERIALIZED VIEW |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED VIEW ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { onlyViews: true },
+          suggestDatabases: { appendDot: true }
+        }
+      });
+    });
+
+    it('should suggest views for "ALTER MATERIALIZED VIEW boo.|"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED VIEW boo.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestTables: { identifierChain: [{ name: 'boo' }], onlyViews: true }
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER MATERIALIZED VIEW boo |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED VIEW boo ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['DISABLE REWRITE', 'ENABLE REWRITE']
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER MATERIALIZED VIEW boo.foo DISABLE |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER MATERIALIZED VIEW boo.foo DISABLE ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['REWRITE']
+        }
+      });
+    });
+  });
+
   describe('ALTER TABLE', () => {
     it('should suggest keywords for "ALTER |"', () => {
       assertAutoComplete({

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.