Procházet zdrojové kódy

HUE-9429 [editor] Extract GRANT, REVOKE and LOAD into separate grammar files for Impala

Johan Ahlen před 5 roky
rodič
revize
c4750f8f45

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/grant/grant_common.jison

@@ -0,0 +1,22 @@
+// 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_EDIT
+ : 'GRANT' 'CURSOR'
+   {
+     parser.suggestKeywords(parser.GRANT_KEYWORDS);
+   }
+ ;

+ 6 - 68
desktop/core/src/desktop/js/parse/jison/sql/impala/sql_grant.jison → desktop/core/src/desktop/js/parse/jison/sql/impala/grant/grant_on.jison

@@ -15,35 +15,20 @@
 // limitations under the License.
 
 DataDefinition
- : GrantStatement
- | RevokeStatement
+ : GrantOnStatement
  ;
 
 DataDefinition_EDIT
- : GrantStatement_EDIT
- | RevokeStatement_EDIT
+ : GrantOnStatement_EDIT
  ;
 
-GrantStatement
- : 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'TO' 'GROUP' RegularOrBacktickedIdentifier
- | 'GRANT' PrivilegeType 'ON' ObjectSpecification 'TO' RegularOrBacktickedIdentifier OptionalWithGrantOption
+GrantOnStatement
+ : 'GRANT' PrivilegeType 'ON' ObjectSpecification 'TO' RegularOrBacktickedIdentifier OptionalWithGrantOption
  | 'GRANT' PrivilegeType 'ON' ObjectSpecification 'TO' GroupRoleOrUser RegularOrBacktickedIdentifier OptionalWithGrantOption
  ;
 
-GrantStatement_EDIT
- : 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']);
-   }
- | 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['TO GROUP']);
-   }
- | 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP']);
-   }
- | 'GRANT' PrivilegeType_EDIT
+GrantOnStatement_EDIT
+ : 'GRANT' PrivilegeType_EDIT
  | 'GRANT' PrivilegeType 'CURSOR'
    {
      if ($2.isCreate) {
@@ -145,50 +130,3 @@ WithGrantOption_EDIT
      parser.suggestKeywords(['OPTION']);
    }
  ;
-
-RevokeStatement
- : 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'FROM' 'GROUP' RegularOrBacktickedIdentifier
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' RegularOrBacktickedIdentifier
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' GroupRoleOrUser RegularOrBacktickedIdentifier
- ;
-
-RevokeStatement_EDIT
- : 'REVOKE' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']);
-   }
- | 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM GROUP']);
-   }
- | 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP']);
-   }
- | 'REVOKE' PrivilegeType_EDIT
- | 'REVOKE' PrivilegeType 'CURSOR'
-   {
-     if ($2.isCreate) {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER']);
-     } else {
-       parser.suggestKeywords(['ON DATABASE', 'ON SERVER', 'ON TABLE', 'ON URI']);
-     }
-   }
- | 'REVOKE' PrivilegeType 'ON' 'CURSOR'
-   {
-     if ($2.isCreate) {
-       parser.suggestKeywords(['DATABASE', 'SERVER']);
-     } else {
-       parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
-     }
-   }
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification_EDIT
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- ;

+ 38 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/grant/grant_role.jison

@@ -0,0 +1,38 @@
+// 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
+ : GrantRoleStatement
+ ;
+
+DataDefinition_EDIT
+ : GrantRoleStatement_EDIT
+ ;
+
+GrantRoleStatement
+ : 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'TO' 'GROUP' RegularOrBacktickedIdentifier
+ ;
+
+GrantRoleStatement_EDIT
+ : 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['TO GROUP']);
+   }
+ | 'GRANT' 'ROLE' RegularOrBacktickedIdentifier 'TO' 'CURSOR'
+   {
+     parser.suggestKeywords(['GROUP']);
+   }
+ ;

+ 4 - 4
desktop/core/src/desktop/js/parse/jison/sql/impala/sql_load.jison → desktop/core/src/desktop/js/parse/jison/sql/impala/load/load_data.jison

@@ -15,21 +15,21 @@
 // limitations under the License.
 
 DataManipulation
- : LoadStatement
+ : LoadDataStatement
  ;
 
 DataManipulation_EDIT
- : LoadStatement_EDIT
+ : LoadDataStatement_EDIT
  ;
 
-LoadStatement
+LoadDataStatement
  : 'LOAD' 'DATA' 'INPATH' HdfsPath OptionalOverwrite 'INTO' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
    {
      parser.addTablePrimary($8);
    }
  ;
 
-LoadStatement_EDIT
+LoadDataStatement_EDIT
  : 'LOAD' 'CURSOR'
    {
      parser.suggestKeywords(['DATA INPATH']);

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/revoke/revoke_common.jison

@@ -0,0 +1,22 @@
+// 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_EDIT
+ : 'REVOKE' 'CURSOR'
+   {
+     parser.suggestKeywords(parser.REVOKE_KEYWORDS);
+   }
+ ;

+ 57 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/revoke/revoke_on.jison

@@ -0,0 +1,57 @@
+// 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
+ : RevokeOnStatement
+ ;
+
+DataDefinition_EDIT
+ : RevokeOnStatement_EDIT
+ ;
+
+RevokeOnStatement
+ : 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' RegularOrBacktickedIdentifier
+ | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' GroupRoleOrUser RegularOrBacktickedIdentifier
+ ;
+
+RevokeOnStatement_EDIT
+ : 'REVOKE' PrivilegeType_EDIT
+ | 'REVOKE' PrivilegeType 'CURSOR'
+   {
+     if ($2.isCreate) {
+       parser.suggestKeywords(['ON DATABASE', 'ON SERVER']);
+     } else {
+       parser.suggestKeywords(['ON DATABASE', 'ON SERVER', 'ON TABLE', 'ON URI']);
+     }
+   }
+ | 'REVOKE' PrivilegeType 'ON' 'CURSOR'
+   {
+     if ($2.isCreate) {
+       parser.suggestKeywords(['DATABASE', 'SERVER']);
+     } else {
+       parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
+     }
+   }
+ | 'REVOKE' PrivilegeType 'ON' ObjectSpecification_EDIT
+ | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'CURSOR'
+   {
+     parser.suggestKeywords(['FROM']);
+   }
+ | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' 'CURSOR'
+   {
+     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
+   }
+ ;

+ 38 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/revoke/revoke_role.jison

@@ -0,0 +1,38 @@
+// 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
+ : RevokeRoleStatement
+ ;
+
+DataDefinition_EDIT
+ : RevokeRoleStatement_EDIT
+ ;
+
+RevokeRoleStatement
+ : 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'FROM' 'GROUP' RegularOrBacktickedIdentifier
+ ;
+
+RevokeRoleStatement_EDIT
+ : 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['FROM GROUP']);
+   }
+ | 'REVOKE' 'ROLE' RegularOrBacktickedIdentifier 'FROM' 'CURSOR'
+   {
+     parser.suggestKeywords(['GROUP']);
+   }
+ ;

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

@@ -25,13 +25,18 @@
     "drop/drop_stats.jison",
     "drop/drop_table.jison",
     "drop/drop_view.jison",
+    "grant/grant_common.jison",
+    "grant/grant_on.jison",
+    "grant/grant_role.jison",
     "invalidate/invalidate_metadata.jison",
+    "load/load_data.jison",
     "refresh/refresh.jison",
+    "revoke/revoke_common.jison",
+    "revoke/revoke_on.jison",
+    "revoke/revoke_role.jison",
     "truncate/truncate_table.jison",
     "sql_error.jison",
-    "sql_grant.jison",
     "sql_insert.jison",
-    "sql_load.jison",
     "sql_main.jison",
     "sql_set.jison",
     "sql_show.jison",
@@ -66,12 +71,17 @@
     "drop/drop_stats.jison",
     "drop/drop_table.jison",
     "drop/drop_view.jison",
+    "grant/grant_common.jison",
+    "grant/grant_on.jison",
+    "grant/grant_role.jison",
     "invalidate/invalidate_metadata.jison",
+    "load/load_data.jison",
     "refresh/refresh.jison",
+    "revoke/revoke_common.jison",
+    "revoke/revoke_on.jison",
+    "revoke/revoke_role.jison",
     "truncate/truncate_table.jison",
-    "sql_grant.jison",
     "sql_insert.jison",
-    "sql_load.jison",
     "sql_main.jison",
     "sql_set.jison",
     "sql_show.jison",

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js


+ 3 - 0
desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js

@@ -26,6 +26,9 @@ import {
 const initSqlParser = function (parser) {
   initSharedAutocomplete(parser);
 
+  parser.GRANT_KEYWORDS = ['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT'];
+  parser.REVOKE_KEYWORDS = ['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT'];
+
   parser.prepareNewStatement = function () {
     linkTablePrimaries();
     parser.commitLocations();

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů