Эх сурвалжийг харах

HUE-9429 [editor] Extract and split ALTER for Impala

Johan Ahlen 5 жил өмнө
parent
commit
28da7be2e6

+ 30 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_common.jison

@@ -0,0 +1,30 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+DataDefinition
+ : AlterStatement
+ ;
+
+DataDefinition_EDIT
+ : AlterStatement_EDIT
+ ;
+
+AlterStatement_EDIT
+ : 'ALTER' 'CURSOR'
+   {
+     parser.suggestKeywords(['DATABASE', 'SCHEMA', 'TABLE', 'VIEW']);
+   }
+ ;

+ 52 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_database.jison

@@ -0,0 +1,52 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+AlterStatement
+ : AlterDatabase
+ ;
+
+AlterStatement_EDIT
+ : AlterDatabase_EDIT
+ ;
+
+AlterDatabase
+ : 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' RoleOrUser RegularOrBacktickedIdentifier
+    {
+      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+    }
+ ;
+
+AlterDatabase_EDIT
+ : 'ALTER' DatabaseOrSchema 'CURSOR'
+   {
+     parser.suggestDatabases();
+   }
+ | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+     parser.suggestKeywords(['SET OWNER']);
+   }
+ | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'CURSOR'
+    {
+      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+      parser.suggestKeywords(['OWNER']);
+    }
+ | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' 'CURSOR'
+   {
+     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
+     parser.suggestKeywords(['ROLE', 'USER']);
+   }
+ ;

+ 3 - 145
desktop/core/src/desktop/js/parse/jison/sql/impala/sql_alter.jison → desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_table.jison

@@ -14,59 +14,12 @@
 // See the License for the specific language governing permissions and
 // See the License for the specific language governing permissions and
 // limitations under the License.
 // limitations under the License.
 
 
-DataDefinition
- : AlterStatement
- ;
-
-DataDefinition_EDIT
- : AlterStatement_EDIT
- ;
-
 AlterStatement
 AlterStatement
- : AlterDatabase
- | AlterTable
- | AlterView
- | CommentOn
+ : AlterTable
  ;
  ;
 
 
 AlterStatement_EDIT
 AlterStatement_EDIT
- : AlterDatabase_EDIT
- | AlterTable_EDIT
- | AlterView_EDIT
- | CommentOn_EDIT
- | 'ALTER' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE', 'VIEW']);
-   }
- ;
-
-AlterDatabase
- : 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' RoleOrUser RegularOrBacktickedIdentifier
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-    }
- ;
-
-AlterDatabase_EDIT
- : 'ALTER' DatabaseOrSchema 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-     parser.suggestKeywords(['SET OWNER']);
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'CURSOR'
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-      parser.suggestKeywords(['OWNER']);
-    }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' 'CURSOR'
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-     parser.suggestKeywords(['ROLE', 'USER']);
-   }
+ : AlterTable_EDIT
  ;
  ;
 
 
 AlterTable
 AlterTable
@@ -255,6 +208,7 @@ OptionalColumn
  | 'COLUMN'
  | 'COLUMN'
  ;
  ;
 
 
+
 ParenthesizedStatsList
 ParenthesizedStatsList
  : '(' StatsList ')'
  : '(' StatsList ')'
  ;
  ;
@@ -475,99 +429,3 @@ PartitionSpecWithLocation
      }
      }
    }
    }
  ;
  ;
-
-AlterView
- : AlterViewLeftSide 'SET' 'OWNER' RoleOrUser RegularOrBacktickedIdentifier
- | AlterViewLeftSide 'AS' QuerySpecification
- | AlterViewLeftSide 'RENAME' 'TO' RegularOrBacktickedIdentifier
- | AlterViewLeftSide 'RENAME' 'TO' RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier
- ;
-
-AlterView_EDIT
- : AlterViewLeftSide_EDIT
- | AlterViewLeftSide 'CURSOR'
-   {
-     parser.suggestKeywords(['AS', 'RENAME TO', 'SET OWNER']);
-   }
- | AlterViewLeftSide 'SET' 'CURSOR'
-   {
-     parser.suggestKeywords(['OWNER ROLE', 'OWNER USER']);
-   }
- | AlterViewLeftSide 'SET' 'OWNER' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE', 'USER']);
-   }
- | AlterViewLeftSide 'SET' 'OWNER' RoleOrUser 'CURSOR'
- | AlterViewLeftSide 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | AlterViewLeftSide 'AS' QuerySpecification_EDIT
- | AlterViewLeftSide 'RENAME' 'CURSOR'
-   {
-     parser.suggestKeywords(['TO']);
-   }
- | AlterViewLeftSide 'RENAME' 'TO' 'CURSOR'
-   {
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-
-AlterViewLeftSide
- : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AlterViewLeftSide_EDIT
- : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- | 'ALTER' 'VIEW' 'CURSOR'
-   {
-     parser.suggestTables({ onlyViews: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-CommentOn
- : 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'IS' NullableComment
-   {
-     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
-   }
- ;
-
-CommentOn_EDIT
- : 'COMMENT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ON DATABASE']);
-   }
- | 'COMMENT' 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['DATABASE']);
-   }
- | 'COMMENT' 'ON' 'DATABASE' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
-     parser.suggestKeywords(['IS']);
-   }
- | 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'IS' 'CURSOR'
-   {
-     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
-     parser.suggestKeywords(['NULL']);
-   }
- ;
-
-NullableComment
- : QuotedValue
- | 'NULL'
- ;

+ 81 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_view.jison

@@ -0,0 +1,81 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+AlterStatement
+ : AlterView
+ ;
+
+AlterStatement_EDIT
+ : AlterView_EDIT
+ ;
+
+AlterView
+ : AlterViewLeftSide 'SET' 'OWNER' RoleOrUser RegularOrBacktickedIdentifier
+ | AlterViewLeftSide 'AS' QuerySpecification
+ | AlterViewLeftSide 'RENAME' 'TO' RegularOrBacktickedIdentifier
+ | AlterViewLeftSide 'RENAME' 'TO' RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier
+ ;
+
+AlterView_EDIT
+ : AlterViewLeftSide_EDIT
+ | AlterViewLeftSide 'CURSOR'
+   {
+     parser.suggestKeywords(['AS', 'RENAME TO', 'SET OWNER']);
+   }
+ | AlterViewLeftSide 'SET' 'CURSOR'
+   {
+     parser.suggestKeywords(['OWNER ROLE', 'OWNER USER']);
+   }
+ | AlterViewLeftSide 'SET' 'OWNER' 'CURSOR'
+   {
+     parser.suggestKeywords(['ROLE', 'USER']);
+   }
+ | AlterViewLeftSide 'SET' 'OWNER' RoleOrUser 'CURSOR'
+ | AlterViewLeftSide 'AS' 'CURSOR'
+   {
+     parser.suggestKeywords(['SELECT']);
+   }
+ | AlterViewLeftSide 'AS' QuerySpecification_EDIT
+ | AlterViewLeftSide 'RENAME' 'CURSOR'
+   {
+     parser.suggestKeywords(['TO']);
+   }
+ | AlterViewLeftSide 'RENAME' 'TO' 'CURSOR'
+   {
+     parser.suggestDatabases({ appendDot: true });
+   }
+ ;
+
+AlterViewLeftSide
+ : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
+   {
+     parser.addTablePrimary($3);
+   }
+ ;
+
+AlterViewLeftSide_EDIT
+ : 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ | 'ALTER' 'VIEW' 'CURSOR'
+   {
+     parser.suggestTables({ onlyViews: true });
+     parser.suggestDatabases({ appendDot: true });
+   }
+ ;

+ 60 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/alter/comment_on.jison

@@ -0,0 +1,60 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+AlterStatement
+ : CommentOn
+ ;
+
+AlterStatement_EDIT
+ : CommentOn_EDIT
+ ;
+
+CommentOn
+ : 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'IS' NullableComment
+   {
+     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
+   }
+ ;
+
+CommentOn_EDIT
+ : 'COMMENT' 'CURSOR'
+   {
+     parser.suggestKeywords(['ON DATABASE']);
+   }
+ | 'COMMENT' 'ON' 'CURSOR'
+   {
+     parser.suggestKeywords(['DATABASE']);
+   }
+ | 'COMMENT' 'ON' 'DATABASE' 'CURSOR'
+   {
+     parser.suggestDatabases();
+   }
+ | 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
+     parser.suggestKeywords(['IS']);
+   }
+ | 'COMMENT' 'ON' 'DATABASE' RegularOrBacktickedIdentifier 'IS' 'CURSOR'
+   {
+     parser.addDatabaseLocation(@4, [ { name: $4 } ]);
+     parser.suggestKeywords(['NULL']);
+   }
+ ;
+
+NullableComment
+ : QuotedValue
+ | 'NULL'
+ ;

+ 12 - 4
desktop/core/src/desktop/js/parse/jison/sql/impala/structure.json

@@ -2,7 +2,11 @@
   "lexer": "sql.jisonlex",
   "lexer": "sql.jisonlex",
   "autocomplete": [
   "autocomplete": [
     "autocomplete_header.jison",
     "autocomplete_header.jison",
-    "sql_alter.jison",
+    "alter/alter_common.jison",
+    "alter/alter_database.jison",
+    "alter/alter_table.jison",
+    "alter/alter_view.jison",
+    "alter/comment_on.jison",
     "sql_analyze.jison",
     "sql_analyze.jison",
     "sql_create.jison",
     "sql_create.jison",
     "sql_drop.jison",
     "sql_drop.jison",
@@ -15,13 +19,17 @@
     "sql_show.jison",
     "sql_show.jison",
     "sql_udf.jison",
     "sql_udf.jison",
     "sql_update.jison",
     "sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/use/use.jison",
     "sql_valueExpression.jison",
     "sql_valueExpression.jison",
     "../generic/autocomplete_footer.jison"
     "../generic/autocomplete_footer.jison"
   ],
   ],
   "syntax": [
   "syntax": [
     "syntax_header.jison",
     "syntax_header.jison",
-    "sql_alter.jison",
+    "alter/alter_common.jison",
+    "alter/alter_database.jison",
+    "alter/alter_table.jison",
+    "alter/alter_view.jison",
+    "alter/comment_on.jison",
     "sql_analyze.jison",
     "sql_analyze.jison",
     "sql_create.jison",
     "sql_create.jison",
     "sql_drop.jison",
     "sql_drop.jison",
@@ -33,7 +41,7 @@
     "sql_show.jison",
     "sql_show.jison",
     "sql_udf.jison",
     "sql_udf.jison",
     "sql_update.jison",
     "sql_update.jison",
-    "../generic/sql_use.jison",
+    "../generic/use/use.jison",
     "sql_valueExpression.jison",
     "sql_valueExpression.jison",
     "../generic/syntax_footer.jison"
     "../generic/syntax_footer.jison"
   ]
   ]

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js


+ 1 - 1
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Alter.test.js

@@ -126,7 +126,7 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
       assertAutoComplete({
       assertAutoComplete({
         beforeCursor: 'ALTER ',
         beforeCursor: 'ALTER ',
         afterCursor: '',
         afterCursor: '',
-        containsKeywords: ['TABLE'],
+        containsKeywords: ['TABLE', 'DATABASE'],
         expectedResult: {
         expectedResult: {
           lowerCase: false
           lowerCase: false
         }
         }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно