瀏覽代碼

HUE-8577 [autocomplete] Add support for Impala ALTER DATABASE statements

Johan Ahlen 6 年之前
父節點
當前提交
c5cb6f2

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

@@ -63,6 +63,10 @@ AlterDatabase
     {
       parser.addDatabaseLocation(@3, [ { name: $3 } ]);
     }
+ | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' '<impala>OWNER' ImpalaRoleOrUser RegularOrBacktickedIdentifier
+    {
+      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+    }
  ;
 
 AlterDatabase_EDIT
@@ -84,6 +88,8 @@ AlterDatabase_EDIT
       parser.addDatabaseLocation(@3, [ { name: $3 } ]);
       if (parser.isHive()) {
         parser.suggestKeywords(['DBPROPERTIES', 'LOCATION', 'OWNER']);
+      } else if (parser.isImpala()) {
+        parser.suggestKeywords(['OWNER']);
       }
     }
  | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' HdfsLocation_EDIT
@@ -95,6 +101,11 @@ AlterDatabase_EDIT
      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
      parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
    }
+ | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' '<impala>OWNER' 'CURSOR'
+   {
+     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+     parser.suggestKeywords(['ROLE', 'USER']);
+   }
  | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' '<hive>OWNER' PrincipalSpecification_EDIT
    {
      parser.addDatabaseLocation(@3, [ { name: $3 } ]);

+ 155 - 101
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSpecAlter.js

@@ -27,126 +27,180 @@
     var assertAutoComplete = SqlTestUtils.assertAutocomplete;
 
     describe('ALTER DATABASE', function () {
-      it('should handle "ALTER DATABASE baa SET DBPROPERTIES (\'boo\'=1, \'baa\'=2);|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE baa SET DBPROPERTIES (\'boo\'=1, \'baa\'=2);',
-          afterCursor: '',
-          dialect: 'hive',
-          noErrors:true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
+      describe('Hive Specific', function () {
+        it('should handle "ALTER DATABASE baa SET DBPROPERTIES (\'boo\'=1, \'baa\'=2);|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE baa SET DBPROPERTIES (\'boo\'=1, \'baa\'=2);',
+            afterCursor: '',
+            dialect: 'hive',
+            noErrors:true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should handle "ALTER SCHEMA baa SET OWNER ROLE boo;|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER SCHEMA baa SET OWNER ROLE boo;',
-          afterCursor: '',
-          dialect: 'hive',
-          noErrors:true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
+        it('should handle "ALTER SCHEMA baa SET OWNER ROLE boo;|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER SCHEMA baa SET OWNER ROLE boo;',
+            afterCursor: '',
+            dialect: 'hive',
+            noErrors:true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should handle "ALTER DATABASE baa SET LOCATION \'/baa/boo\';|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE baa SET LOCATION \'/baa/boo\';',
-          afterCursor: '',
-          dialect: 'hive',
-          noErrors:true,
-          containsKeywords: ['SELECT'],
-          expectedResult: {
-            lowerCase: false
-          }
+        it('should handle "ALTER DATABASE baa SET LOCATION \'/baa/boo\';|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE baa SET LOCATION \'/baa/boo\';',
+            afterCursor: '',
+            dialect: 'hive',
+            noErrors:true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "ALTER |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER ',
-          afterCursor: '',
-          dialect: 'hive',
-          containsKeywords: ['DATABASE', 'SCHEMA'],
-          expectedResult: {
-            lowerCase: false
-          }
+        it('should suggest keywords for "ALTER |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER ',
+            afterCursor: '',
+            dialect: 'hive',
+            containsKeywords: ['DATABASE', 'SCHEMA'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
         });
-      });
 
-      it('should suggest databases for "ALTER DATABASE |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestDatabases: {}
-          }
+        it('should suggest databases for "ALTER DATABASE |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestDatabases: {}
+            }
+          });
         });
-      });
 
-      it('should suggest databases for "ALTER SCHEMA |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER SCHEMA ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestDatabases: {}
-          }
+        it('should suggest databases for "ALTER SCHEMA |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER SCHEMA ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestDatabases: {}
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "ALTER SCHEMA boo |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER SCHEMA boo ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['SET DBPROPERTIES', 'SET LOCATION', 'SET OWNER']
-          }
+        it('should suggest keywords for "ALTER SCHEMA boo |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER SCHEMA boo ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['SET DBPROPERTIES', 'SET LOCATION', 'SET OWNER']
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "ALTER DATABASE boo SET |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE boo SET ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DBPROPERTIES', 'LOCATION', 'OWNER']
-          }
+        it('should suggest keywords for "ALTER DATABASE boo SET |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE boo SET ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['DBPROPERTIES', 'LOCATION', 'OWNER']
+            }
+          });
         });
-      });
 
-      it('should suggest keywords for "ALTER DATABASE boo SET OWNER |"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE boo SET OWNER ',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['GROUP', 'ROLE', 'USER']
-          }
+        it('should suggest keywords for "ALTER DATABASE boo SET OWNER |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE boo SET OWNER ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['GROUP', 'ROLE', 'USER']
+            }
+          });
+        });
+
+        it('should suggest hdfs for "ALTER DATABASE boo SET LOCATION \'/|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE boo SET LOCATION \'/',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestHdfs: { path: '/' }
+            }
+          });
         });
       });
 
-      it('should suggest hdfs for "ALTER DATABASE boo SET LOCATION \'/|"', function() {
-        assertAutoComplete({
-          beforeCursor: 'ALTER DATABASE boo SET LOCATION \'/',
-          afterCursor: '',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestHdfs: { path: '/' }
-          }
+      describe('Impala Specific', function () {
+        it('should handle "ALTER DATABASE db SET OWNER USER usr;|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE db SET OWNER USER usr;',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should handle "ALTER DATABASE db SET OWNER ROLE usr;|"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE db SET OWNER ROLE usr;',
+            afterCursor: '',
+            dialect: 'impala',
+            noErrors: true,
+            containsKeywords: ['SELECT'],
+            expectedResult: {
+              lowerCase: false
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER DATABASE boo SET |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE boo SET ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['OWNER']
+            }
+          });
+        });
+
+        it('should suggest keywords for "ALTER DATABASE boo SET OWNER |"', function() {
+          assertAutoComplete({
+            beforeCursor: 'ALTER DATABASE boo SET OWNER ',
+            afterCursor: '',
+            dialect: 'impala',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['ROLE', 'USER']
+            }
+          });
         });
       });
     });

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


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


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