Forráskód Böngészése

HUE-9370 [editor] Reduce duplication for ALTER, DROP and SHOW in the Presto parser

This also introduces a means of controlling keyword suggestions outside the grammar.
Johan Ahlen 5 éve
szülő
commit
936a3aefeb
35 módosított fájl, 470 hozzáadás és 2937 törlés
  1. 4 34
      desktop/core/src/desktop/js/parse/jison/sql/hive/alter/sql_alter.jison
  2. 58 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/alter/sql_alter_materialized_view.jison
  3. 45 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/common/sql_table_constraint.jison
  4. 1 2
      desktop/core/src/desktop/js/parse/jison/sql/hive/drop/sql_drop.jison
  5. 48 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/drop/sql_drop_materialized_view.jison
  6. 1 1
      desktop/core/src/desktop/js/parse/jison/sql/hive/show/sql_show.jison
  7. 44 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/show/sql_show_materialized_views.jison
  8. 0 867
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_alter.jison
  9. 0 29
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_create.jison
  10. 0 348
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_drop.jison
  11. 86 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_msck.jison
  12. 0 535
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_show.jison
  13. 16 6
      desktop/core/src/desktop/js/parse/jison/sql/hive/structure.json
  14. 27 0
      desktop/core/src/desktop/js/parse/jison/sql/presto/common/table_constraint.jison
  15. 0 378
      desktop/core/src/desktop/js/parse/jison/sql/presto/sql_grant.jison
  16. 0 536
      desktop/core/src/desktop/js/parse/jison/sql/presto/sql_insert.jison
  17. 52 0
      desktop/core/src/desktop/js/parse/jison/sql/presto/sql_msck.jison
  18. 18 14
      desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json
  19. 2 20
      desktop/core/src/desktop/js/parse/sql/druid/sqlParseSupport.js
  20. 2 20
      desktop/core/src/desktop/js/parse/sql/elasticsearch/sqlParseSupport.js
  21. 2 21
      desktop/core/src/desktop/js/parse/sql/flink/sqlParseSupport.js
  22. 2 21
      desktop/core/src/desktop/js/parse/sql/generic/sqlParseSupport.js
  23. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js
  24. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js
  25. 7 0
      desktop/core/src/desktop/js/parse/sql/hive/keywords.json
  26. 5 21
      desktop/core/src/desktop/js/parse/sql/hive/sqlParseSupport.js
  27. 11 0
      desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Alter.test.js
  28. 2 21
      desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js
  29. 2 21
      desktop/core/src/desktop/js/parse/sql/ksql/sqlParseSupport.js
  30. 2 21
      desktop/core/src/desktop/js/parse/sql/phoenix/sqlParseSupport.js
  31. 6 0
      desktop/core/src/desktop/js/parse/sql/presto/keywords.json
  32. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js
  33. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js
  34. 2 21
      desktop/core/src/desktop/js/parse/sql/presto/sqlParseSupport.js
  35. 25 0
      desktop/core/src/desktop/js/parse/sql/sqlParseUtils.js

+ 4 - 34
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_alter.jison → desktop/core/src/desktop/js/parse/jison/sql/hive/alter/sql_alter.jison

@@ -27,7 +27,6 @@ AlterStatement
  | AlterIndex
  | AlterTable
  | AlterView
- | Msck
  | ReloadFunction
  ;
 
@@ -36,11 +35,10 @@ AlterStatement_EDIT
  | AlterIndex_EDIT
  | AlterTable_EDIT
  | AlterView_EDIT
- | Msck_EDIT
  | ReloadFunction_EDIT
  | 'ALTER' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'INDEX', 'SCHEMA', 'TABLE', 'VIEW']);
+     parser.suggestKeywords('ALTER');
    }
  ;
 
@@ -125,7 +123,7 @@ AlterIndex_EDIT
 AlterTable
  : AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification
- | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ | AlterTableLeftSide 'ADD' TableConstraint
  | AlterTableLeftSide 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
  | AlterTableLeftSide ClusteredBy
  | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
@@ -147,6 +145,7 @@ AlterTable
 AlterTable_EDIT
  : AlterTableLeftSide_EDIT
  | AlterTableLeftSide_EDIT 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
+ | AlterTableLeftSide_EDIT TableConstraint
  | AlterTableLeftSide_EDIT 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
  | AlterTableLeftSide_EDIT ClusteredBy
  | AlterTableLeftSide_EDIT 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
@@ -194,7 +193,7 @@ AlterTable_EDIT
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' 'CURSOR'
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
    {
-     parser.suggestKeywords(['FOREIGN KEY', 'PRIMARY KEY']);
+     parser.suggestKeywords('ALTER TABLE ADD CONSTRAINT identifier');
    }
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification_EDIT
  | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
@@ -749,35 +748,6 @@ AlterViewLeftSide_EDIT
    }
  ;
 
-Msck
- : 'MSCK' 'REPAIR' 'TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-Msck_EDIT
- : 'MSCK' 'CURSOR'
-   {
-     parser.suggestKeywords(['REPAIR TABLE']);
-   }
- | 'MSCK' 'REPAIR' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'MSCK' 'REPAIR' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'MSCK' 'REPAIR' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- ;
-
 ReloadFunction
  : 'RELOAD' 'FUNCTION'
  ;

+ 58 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/alter/sql_alter_materialized_view.jison

@@ -0,0 +1,58 @@
+// 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
+ : AlterMaterializedView
+ ;
+
+AlterStatement_EDIT
+ : AlterMaterializedView_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']);
+   }
+ ;

+ 45 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/common/sql_table_constraint.jison

@@ -0,0 +1,45 @@
+// 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.
+
+TableConstraint
+ : TableConstraintLeftPart OptionalDisable OptionalNovalidate OptionalRelyOrNorely
+ ;
+
+TableConstraint_EDIT
+ : TableConstraintLeftPart_EDIT OptionalDisable OptionalNovalidate OptionalRelyOrNorely
+ | TableConstraintLeftPart OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
+   {
+     parser.suggestKeywordsForOptionalsLR([$4, $3, $2], [
+       [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
+       { value: 'NOVALIDATE', weight: 2 },
+       { value: 'DISABLE', weight: 3 }
+     ]);
+   }
+ ;
+
+TableConstraintLeftPart
+ : 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CHECK' '(' ValueExpression ')'
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier 'UNIQUE' ParenthesizedColumnList
+ ;
+
+TableConstraintLeftPart_EDIT
+ : 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['CHECK', 'FOREIGN KEY', 'UNIQUE']);
+   }
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
+ ;

+ 1 - 2
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_drop.jison → desktop/core/src/desktop/js/parse/jison/sql/hive/drop/sql_drop.jison

@@ -53,7 +53,7 @@ DropStatement_EDIT
  | TruncateTableStatement_EDIT
  | 'DROP' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
+     parser.suggestKeywords('DROP');
    }
  ;
 
@@ -158,7 +158,6 @@ OptionalPurge
  | 'PURGE'
  ;
 
-
 DropIndexStatement
  : 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier
    {

+ 48 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/drop/sql_drop_materialized_view.jison

@@ -0,0 +1,48 @@
+// 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.
+
+DropStatement
+ : DropMaterializedViewStatement
+ ;
+
+DropStatement_EDIT
+ : DropMaterializedViewStatement_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;
+     }
+   }
+ ;

+ 1 - 1
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_show.jison → desktop/core/src/desktop/js/parse/jison/sql/hive/show/sql_show.jison

@@ -46,7 +46,7 @@ ShowStatement
 ShowStatement_EDIT
  : 'SHOW' 'CURSOR'
    {
-     parser.suggestKeywords(['COLUMNS', 'COMPACTIONS', 'CONF', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FORMATTED', 'FUNCTIONS', 'GRANT', 'INDEX', 'INDEXES', 'LOCKS', 'PARTITIONS', 'PRINCIPALS', 'ROLE GRANT', 'ROLES', 'SCHEMAS', 'TABLE EXTENDED', 'TABLES', 'TBLPROPERTIES', 'TRANSACTIONS', 'VIEWS']);
+     parser.suggestKeywords('SHOW');
    }
  | 'SHOW' 'CURSOR' RegularOrBackTickedSchemaQualifiedName
    {

+ 44 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/show/sql_show_materialized_views.jison

@@ -0,0 +1,44 @@
+// 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.
+
+ShowStatement
+ : ShowMaterializedViewsStatement
+ ;
+
+ShowStatement_EDIT
+ : ShowMaterializedViewsStatement_EDIT
+ ;
+
+ShowMaterializedViewsStatement
+ : 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike
+ ;
+
+ShowMaterializedViewsStatement_EDIT
+ : 'SHOW' 'MATERIALIZED' 'CURSOR'
+   {
+     parser.suggestKeywords(['VIEWS']);
+   }
+ | 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
+   {
+     if (!$5 && !$4) {
+       parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
+     } else if (!$5) {
+       parser.suggestKeywords(['LIKE']);
+     }
+   }
+ | 'SHOW' 'MATERIALIZED' 'VIEWS' InOrFromDatabase_EDIT OptionalLike
+ | 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase Like_EDIT
+ ;

+ 0 - 867
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_alter.jison

@@ -1,867 +0,0 @@
-// 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
- : AlterDatabase
- | AlterIndex
- | AlterMaterializedView
- | AlterTable
- | AlterView
- | Msck
- | ReloadFunction
- ;
-
-AlterStatement_EDIT
- : AlterDatabase_EDIT
- | AlterIndex_EDIT
- | AlterMaterializedView_EDIT
- | AlterTable_EDIT
- | AlterView_EDIT
- | Msck_EDIT
- | ReloadFunction_EDIT
- | 'ALTER' 'CURSOR'
-   {
-     parser.suggestKeywords(['DATABASE', 'INDEX', 'MATERIALIZED VIEW', 'SCHEMA', 'TABLE', 'VIEW']);
-   }
- ;
-
-AlterDatabase
- : 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-    }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' HdfsLocation
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-    }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' PrincipalSpecification
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-    }
- ;
-
-AlterDatabase_EDIT
- : 'ALTER' DatabaseOrSchema 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-     parser.suggestKeywords(['SET DBPROPERTIES', 'SET LOCATION', 'SET OWNER']);
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'CURSOR'
-    {
-      parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-      parser.suggestKeywords(['DBPROPERTIES', 'LOCATION', 'OWNER']);
-    }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' HdfsLocation_EDIT
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' 'CURSOR'
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'ALTER' DatabaseOrSchema RegularOrBacktickedIdentifier 'SET' 'OWNER' PrincipalSpecification_EDIT
-   {
-     parser.addDatabaseLocation(@3, [ { name: $3 } ]);
-   }
- ;
-
-AlterIndex
- : 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'REBUILD'
-   {
-     parser.addTablePrimary($5);
-   }
- ;
-
-AlterIndex_EDIT
- : 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
- | 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
-   {
-     parser.addTablePrimary($5);
-   }
- | 'ALTER' 'INDEX' RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     if (!$6) {
-       parser.suggestKeywords(['PARTITION', 'REBUILD']);
-     } else {
-       parser.suggestKeywords(['REBUILD']);
-     }
-   }
- ;
-
-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
- | AlterTableLeftSide 'ADD' TableConstraint
- | AlterTableLeftSide 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
- | AlterTableLeftSide ClusteredBy
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
- | AlterTableLeftSide ExchangeSpecification
- | AlterTableLeftSide 'RECOVER' 'PARTITIONS'
- | AlterTableLeftSide 'TOUCH' OptionalPartitionSpec
- | AlterTableLeftSide ArchiveOrUnArchive PartitionSpec
- | AlterTableLeftSide 'NOT' 'SKEWED'
- | AlterTableLeftSide 'NOT' 'STORED_AS_DIRECTORIES'
- | AlterTableLeftSide 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList
- | AlterTableLeftSide 'SET' 'OWNER' PrincipalSpecification
- | AlterTableLeftSide PartitionSpec 'RENAME' 'TO' PartitionSpec
- | AlterTableLeftSide PartitionSpec 'CHANGE' 'COLUMN' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
- | AlterTableLeftSide DropOperations
- | AlterTableLeftSide OptionalPartitionOperations
- | AlterTableLeftSide PartitionSpec OptionalPartitionOperations
- ;
-
-AlterTable_EDIT
- : AlterTableLeftSide_EDIT
- | AlterTableLeftSide_EDIT 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs
- | AlterTableLeftSide_EDIT TableConstraint
- | AlterTableLeftSide_EDIT 'RENAME' 'TO' RegularOrBackTickedSchemaQualifiedName
- | AlterTableLeftSide_EDIT ClusteredBy
- | AlterTableLeftSide_EDIT 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
- | AlterTableLeftSide_EDIT ExchangeSpecification
- | AlterTableLeftSide_EDIT 'RECOVER' 'PARTITIONS'
- | AlterTableLeftSide_EDIT 'TOUCH' OptionalPartitionSpec
- | AlterTableLeftSide_EDIT ArchiveOrUnArchive PartitionSpec
- | AlterTableLeftSide_EDIT 'NOT' 'SKEWED'
- | AlterTableLeftSide_EDIT 'NOT' 'STORED_AS_DIRECTORIES'
- | AlterTableLeftSide_EDIT 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList
- | AlterTableLeftSide_EDIT 'SET' 'OWNER' PrincipalSpecification
- | AlterTableLeftSide_EDIT PartitionSpec 'RENAME' 'TO' PartitionSpec
- | AlterTableLeftSide_EDIT PartitionSpec 'CHANGE' 'COLUMN' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
- | AlterTableLeftSide_EDIT DropOperations
- | AlterTableLeftSide_EDIT OptionalPartitionOperations
- | AlterTableLeftSide_EDIT PartitionSpec OptionalPartitionOperations
- | AlterTableLeftSide 'ADD' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 3 }, { value: 'COLUMNS', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }, {  value: 'PARTITION', weight: 1 }]);
-     } else {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | AlterTableLeftSide 'REPLACE' 'CURSOR'
-   {
-     parser.suggestKeywords(['COLUMNS']);
-   }
- | AlterTableLeftSide 'ADD' OptionalIfNotExists_EDIT
- | AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec HdfsLocation_EDIT OptionalPartitionSpecs
- | AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs_EDIT
- | AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs 'CURSOR'
-   {
-     if (!$5 && !$6) {
-       parser.suggestKeywords(['LOCATION', 'PARTITION']);
-     } else if ($6 && $6.suggestKeywords) {
-       var keywords = parser.createWeightedKeywords($6.suggestKeywords, 2);
-       keywords.push({ value: 'PARTITION', weight: 1 });
-       parser.suggestKeywords(keywords);
-     } else {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | AlterTableLeftSide 'ADD' OptionalIfNotExists PartitionSpec_EDIT OptionalHdfsLocation OptionalPartitionSpecs
- | AlterTableLeftSide 'ADD' 'CONSTRAINT' 'CURSOR'
- | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['CHECK', 'FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE']);
-   }
- | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier PrimaryKeySpecification_EDIT
- | AlterTableLeftSide 'ADD' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
- | AlterTableLeftSide ArchiveOrUnArchive 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AlterTableLeftSide ArchiveOrUnArchive PartitionSpec_EDIT
- | AlterTableLeftSide ClusteredBy_EDIT
- | AlterTableLeftSide ExchangeSpecification_EDIT
- | AlterTableLeftSide 'NOT' 'CURSOR'
-   {
-     parser.suggestKeywords(['SKEWED', 'STORED AS DIRECTORIES']);
-   }
- | AlterTableLeftSide 'NOT' 'STORED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS DIRECTORIES']);
-   }
- | AlterTableLeftSide 'NOT' 'STORED' 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['DIRECTORIES']);
-   }
- | AlterTableLeftSide PartitionSpec 'RENAME' 'CURSOR'
-   {
-     parser.suggestKeywords(['TO PARTITION']);
-   }
- | AlterTableLeftSide PartitionSpec 'RENAME' 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AlterTableLeftSide 'RECOVER' 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITIONS']);
-   }
- | AlterTableLeftSide 'SET' 'SKEWED' 'CURSOR'
-   {
-     parser.suggestKeywords(['LOCATION']);
-   }
- | AlterTableLeftSide 'SET' 'SKEWED_LOCATION' ParenthesizedSkewedLocationList_EDIT
- | AlterTableLeftSide 'SKEWED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | AlterTableLeftSide 'SET' 'OWNER' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | AlterTableLeftSide 'SET' 'OWNER' PrincipalSpecification_EDIT
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList_EDIT
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList_EDIT 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories 'CURSOR'
-   {
-     if (!$7) {
-       parser.suggestKeywords(['STORED AS DIRECTORIES']);
-     }
-   }
- | AlterTableLeftSide 'SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories_EDIT
- | AlterTableLeftSide 'TOUCH' 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AlterTableLeftSide 'TOUCH' OptionalPartitionSpec_EDIT
- | AlterTableLeftSide OptionalPartitionOperations_EDIT
- | AlterTableLeftSide DropOperations_EDIT
- | AlterTableLeftSide 'CURSOR'
-   {
-     parser.suggestKeywords(['ADD COLUMNS', 'ADD IF NOT EXISTS', 'ADD PARTITION', 'ARCHIVE PARTITION', 'CHANGE',
-       'CLUSTERED BY', 'CONCATENATE', 'COMPACT', 'DISABLE NO_DROP', 'DISABLE OFFLINE', 'DROP', 'ENABLE NO_DROP',
-       'ENABLE OFFLINE', 'EXCHANGE PARTITION', 'NOT SKEWED', 'NOT STORED AS DIRECTORIES', 'PARTITION',
-       'RECOVER PARTITIONS', 'RENAME TO', 'REPLACE COLUMNS', 'SET FILEFORMAT', 'SET LOCATION', 'SET OWNER', 'SET SERDE',
-       'SET SERDEPROPERTIES', 'SET SKEWED LOCATION', 'SET TBLPROPERTIES', 'SKEWED BY', 'TOUCH', 'UNARCHIVE PARTITION']);
-   }
- | AlterTableLeftSide PartitionSpec 'CURSOR'
-   {
-     parser.suggestKeywords(['ADD COLUMNS', 'CHANGE', 'COMPACT', 'CONCATENATE', 'DISABLE NO_DROP', 'DISABLE OFFLINE',
-       'ENABLE NO_DROP', 'ENABLE OFFLINE', 'RENAME TO PARTITION', 'REPLACE COLUMNS', 'SET FILEFORMAT', 'SET LOCATION',
-       'SET SERDE', 'SET SERDEPROPERTIES']);
-   }
- | AlterTableLeftSide PartitionSpec AddOrReplace 'CURSOR'
-   {
-     parser.suggestKeywords(['COLUMNS']);
-   }
- | AlterTableLeftSide PartitionSpec 'SET' 'CURSOR'
-   {
-     parser.suggestKeywords(['FILEFORMAT', 'LOCATION', 'SERDE', 'SERDEPROPERTIES']);
-   }
- | AlterTableLeftSide 'SET' 'CURSOR'
-   {
-     parser.suggestKeywords(['FILEFORMAT', 'LOCATION', 'OWNER', 'SERDE', 'SERDEPROPERTIES', 'SKEWED LOCATION', 'TBLPROPERTIES']);
-   }
- | AlterTableLeftSide PartitionSpec OptionalPartitionOperations_EDIT
- | AlterTableLeftSide 'RENAME' 'CURSOR'
-   {
-     parser.suggestKeywords(['TO']);
-   }
- | AlterTableLeftSide 'RENAME' 'TO' 'CURSOR'
-   {
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-ParenthesizedStatsList
- : '(' StatsList ')'
- ;
-
-ParenthesizedStatsList_EDIT
- : '(' StatsList_EDIT RightParenthesisOrError
- ;
-
-StatsList
- : StatsAssignment
- | StatsList ',' StatsAssignment
- ;
-
-StatsList_EDIT
- : StatsAssignment_EDIT
- | StatsList ',' StatsAssignment_EDIT
- | StatsList ',' StatsAssignment_EDIT ',' StatsList
- | StatsAssignment_EDIT ',' StatsList
- ;
-
-StatsAssignment
- : QuotedValue '=' QuotedValue
- ;
-
-StatsAssignment_EDIT
- : 'CURSOR'
-   {
-     parser.suggestIdentifiers(['\'avgSize\'', '\'maxSize\'', '\'numDVs\'', '\'numNulls\'']);
-   }
- ;
-
-OptionalPartitionOperations
- : 'SET' 'FILEFORMAT' FileFormat
- | 'SET' HdfsLocation
- | 'SET' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
- | 'SET' 'SERDE' QuotedValue OptionalWithSerdeproperties
- | 'SET' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
- | AddReplaceColumns
- | 'CONCATENATE'
- | 'COMPACT' QuotedValue OptionalAndWait OptionalWithOverwriteTblProperties
- | EnableOrDisable NoDropOrOffline
- | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst OptionalCascadeOrRestrict
-   {
-     parser.addColumnLocation($3.location, [ $3.identifier ]);
-   }
- ;
-
-OptionalPartitionOperations_EDIT
- : AddReplaceColumns_EDIT
- | 'CHANGE' OptionalColumn 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords(['COLUMN']);
-     }
-     parser.suggestColumns();
-   }
- | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification_EDIT OptionalAfterOrFirst OptionalCascadeOrRestrict
-   {
-     parser.addColumnLocation($3.location, [ $3.identifier ]);
-   }
- | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst OptionalCascadeOrRestrict 'CURSOR'
-   {
-     if (!$5 && !$6) {
-       if ($4.suggestKeywords) {
-         var keywords = parser.createWeightedKeywords($4.suggestKeywords, 3);
-         keywords = keywords.concat([{ value: 'AFTER', weight: 2 }, { value: 'FIRST', weight: 2 }, { value: 'CASCADE', weight: 1 }, { value: 'RESTRICT', weight: 1 }]);
-         parser.suggestKeywords(keywords);
-       } else {
-         parser.suggestKeywords([{ value: 'AFTER', weight: 2 }, { value: 'FIRST', weight: 2 }, { value: 'CASCADE', weight: 1 }, { value: 'RESTRICT', weight: 1 }]);
-       }
-     } else if ($5 && !$6) {
-       parser.suggestKeywords(['CASCADE', 'RESTRICT']);
-     }
-     parser.addColumnLocation($3.location, [ $3.identifier ]);
-   }
- | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification OptionalAfterOrFirst_EDIT OptionalCascadeOrRestrict
-   {
-     parser.addColumnLocation($3.location, [ $3.identifier ]);
-   }
- | 'COMPACT' QuotedValue OptionalAndWait OptionalWithOverwriteTblProperties 'CURSOR'
-   {
-     if (!$3 && !$4) {
-       parser.suggestKeywords(['AND WAIT', 'WITH OVERWRITE TBLPROPERTIES']);
-     } else if (!$4) {
-       parser.suggestKeywords(['WITH OVERWRITE TBLPROPERTIES']);
-     }
-   }
- | 'COMPACT' QuotedValue AndWait_EDIT OptionalWithOverwriteTblProperties
- | 'COMPACT' QuotedValue OptionalAndWait WithOverwriteTblProperties_EDIT
- | EnableOrDisable 'CURSOR'
-   {
-     parser.suggestKeywords(['NO_DROP', 'OFFLINE']);
-   }
- | EnableOrDisable NoDropOrOffline_EDIT
- | 'SET' 'FILEFORMAT' 'CURSOR'
-   {
-     parser.suggestFileFormats();
-   }
- | 'SET' HdfsLocation_EDIT
- | 'SET' 'SERDE' QuotedValue OptionalWithSerdeproperties 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['WITH SERDEPROPERTIES']);
-     }
-   }
- | 'SET' 'SERDE' QuotedValue WithSerdeproperties_EDIT
- ;
-
-OptionalAndWait
- :
- | 'AND' 'WAIT'
- ;
-
-AndWait_EDIT
- : 'AND' 'CURSOR'
-   {
-     parser.suggestKeywords(['WAIT']);
-   }
- ;
-
-OptionalWithOverwriteTblProperties
- :
- | 'WITH' 'OVERWRITE' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-WithOverwriteTblProperties_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['OVERWRITE TBLPROPERTIES']);
-   }
- | 'WITH' 'OVERWRITE' 'CURSOR'
-   {
-     parser.suggestKeywords(['TBLPROPERTIES']);
-   }
- ;
-
-AddReplaceColumns
- : AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict
- ;
-
-AddReplaceColumns_EDIT
- : AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList_EDIT OptionalCascadeOrRestrict
- | AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList OptionalCascadeOrRestrict 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['CASCADE', 'RESTRICT']);
-     }
-   }
- ;
-
-ExchangeSpecification
- : 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName
- ;
-
-ExchangeSpecification_EDIT
- : 'EXCHANGE' 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | 'EXCHANGE' ExchangePartitionSpec 'CURSOR'
-   {
-     parser.suggestKeywords(['WITH TABLE']);
-   }
- | 'EXCHANGE' ExchangePartitionSpec 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'EXCHANGE' ExchangePartitionSpec 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName_EDIT
- | 'EXCHANGE' ExchangePartitionSpec_EDIT
- | 'EXCHANGE' ExchangePartitionSpec_EDIT 'WITH' 'TABLE' RegularOrBackTickedSchemaQualifiedName
- ;
-
-ExchangePartitionSpec
- : 'PARTITION' '(' OneOrMorePartitionSpecLists ')'
- | 'PARTITION' '(' PartitionSpecList ')'
- ;
-
-ExchangePartitionSpec_EDIT
- : 'PARTITION' '(' OneOrMorePartitionSpecLists_EDIT RightParenthesisOrError
- | 'PARTITION' '(' PartitionSpecList_EDIT RightParenthesisOrError
- ;
-
-OneOrMorePartitionSpecLists
- : '(' PartitionSpecList ')'
- | OneOrMorePartitionSpecLists ',' '(' PartitionSpecList ')'
- ;
-
-OneOrMorePartitionSpecLists_EDIT
- : '(' PartitionSpecList_EDIT RightParenthesisOrError
- | OneOrMorePartitionSpecLists ',' '(' PartitionSpecList_EDIT RightParenthesisOrError
- ;
-
-DropOperations
- : 'DROP' OptionalIfExists OneOrMorePartitionSpecs OptionalPurge
- | 'DROP' 'CONSTRAINT' RegularOrBacktickedIdentifier
- ;
-
-DropOperations_EDIT
- : 'DROP' OptionalIfExists 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords([{ value: 'CONSTRAINT', weight: 1}, { value: 'PARTITION', weight: 1}, { value: 'IF EXISTS', weight: 2 }]);
-     } else {
-        parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | 'DROP' OptionalIfExists OneOrMorePartitionSpecs_EDIT OptionalPurge
- | 'DROP' OptionalIfExists OneOrMorePartitionSpecs OptionalPurge 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['PURGE']);
-     }
-   }
- | 'DROP' 'CONSTRAINT' 'CURSOR'
- | 'DROP' OptionalIfExists_EDIT
- | 'DROP' ColumnIdentifier_EDIT
- ;
-
-AlterTableLeftSide
- : 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AlterTableLeftSide_EDIT
- : 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyTables = true;
-     }
-   }
- | 'ALTER' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
-AddOrReplace
- : 'ADD'
- | 'REPLACE'
- ;
-
-OptionalAfterOrFirst
- :
- | AfterOrFirst ColumnIdentifier
- ;
-
-AfterOrFirst
- : 'AFTER'
- | 'FIRST'
- ;
-
-OptionalAfterOrFirst_EDIT
- : AfterOrFirst 'CURSOR'
-   {
-     parser.suggestColumns();
-   }
- | AfterOrFirst ColumnIdentifier_EDIT
- ;
-
-OptionalColumn
- :
- | 'COLUMN'
- ;
-
-EnableOrDisable
- : 'ENABLE'
- | 'DISABLE'
- ;
-
-NoDropOrOffline
- : 'NO_DROP' OptionalCascade
- | 'OFFLINE'
- ;
-
-NoDropOrOffline_EDIT
- : 'NO_DROP' OptionalCascade 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords(['CASCADE']);
-     }
-   }
- ;
-
-ArchiveOrUnArchive
- : 'ARCHIVE'
- | 'UNARCHIVE'
- ;
-
-OneOrMorePartitionSpecs
- : PartitionSpec
- | OneOrMorePartitionSpecs ',' PartitionSpec
- ;
-
-OneOrMorePartitionSpecs_EDIT
- : PartitionSpec_EDIT
- | OneOrMorePartitionSpecs ',' AnyCursor
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | OneOrMorePartitionSpecs ',' AnyCursor ',' OneOrMorePartitionSpecs
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | AnyCursor ',' OneOrMorePartitionSpecs
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- | OneOrMorePartitionSpecs ',' PartitionSpec_EDIT
- | PartitionSpec_EDIT ',' OneOrMorePartitionSpecs
- | OneOrMorePartitionSpecs ',' PartitionSpec_EDIT ',' OneOrMorePartitionSpecs
- ;
-
-OptionalPartitionSpecs
- :
- | PartitionSpecWithLocationList
- ;
-
-PartitionSpecWithLocationList
- : PartitionSpecWithLocation
- | PartitionSpecWithLocationList PartitionSpecWithLocation  -> $2
- ;
-
-OptionalPartitionSpecs_EDIT
- : PartitionSpecWithLocation_EDIT
- | PartitionSpecWithLocation_EDIT PartitionSpecWithLocationList
- | PartitionSpecWithLocationList PartitionSpecWithLocation_EDIT
- | PartitionSpecWithLocationList PartitionSpecWithLocation_EDIT PartitionSpecWithLocationList
- ;
-
-PartitionSpecWithLocation_EDIT
- : PartitionSpec HdfsLocation_EDIT
- | PartitionSpec_EDIT OptionalHdfsLocation
- ;
-
-PartitionSpecWithLocation
- : PartitionSpec OptionalHdfsLocation
-   {
-     if (!$2) {
-       $$ = { suggestKeywords: ['LOCATION'] };
-     }
-   }
- ;
-
-ParenthesizedSkewedLocationList
- : '(' SkewedLocationList ')'
- ;
-
-ParenthesizedSkewedLocationList_EDIT
- : '(' SkewedLocationList_EDIT RightParenthesisOrError
- ;
-
-SkewedLocationList
- : SkewedLocation
- | SkewedLocationList ',' SkewedLocation
- ;
-
-SkewedLocationList_EDIT
- : SkewedLocation_EDIT
- | SkewedLocationList ',' SkewedLocation_EDIT
- | SkewedLocationList ',' SkewedLocation_EDIT ',' SkewedLocationList
- | SkewedLocation_EDIT ',' SkewedLocationList
- ;
-
-SkewedLocation
- : ColumnReference '=' QuotedValue
- ;
-
-SkewedLocation_EDIT
- : AnyCursor
-   {
-     parser.suggestColumns();
-   }
- | ColumnReference_EDIT
- | AnyCursor '=' QuotedValue
-   {
-     parser.suggestColumns();
-   }
- | ColumnReference_EDIT '=' QuotedValue
- | ColumnReferences '=' QuotedValue
- ;
-
-OptionalStoredAsDirectories
- :
- | 'STORED_AS_DIRECTORIES'
- ;
-
-OptionalStoredAsDirectories_EDIT
- : 'STORED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS DIRECTORIES']);
-   }
- | 'STORED' 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['DIRECTORIES']);
-   }
- ;
-
-AlterView
- : AlterViewLeftSide 'SET' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
- | AlterViewLeftSide 'AS' QuerySpecification
- ;
-
-AlterView_EDIT
- : AlterViewLeftSide_EDIT
- | AlterViewLeftSide 'CURSOR'
-   {
-     parser.suggestKeywords(['AS', 'SET TBLPROPERTIES']);
-   }
- | AlterViewLeftSide 'SET' 'CURSOR'
-   {
-     parser.suggestKeywords(['TBLPROPERTIES']);
-   }
- | AlterViewLeftSide 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | AlterViewLeftSide 'AS' QuerySpecification_EDIT
- ;
-
-
-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 });
-   }
- ;
-
-Msck
- : 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-Msck_EDIT
- : 'MSCK' OptionalRepair 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords(['TABLE', 'REPAIR TABLE']);
-     } else {
-       parser.suggestKeywords(['TABLE']);
-     }
-   }
- | 'MSCK' OptionalRepair 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier AddDropSyncPartitions_EDIT
-   {
-     parser.addTablePrimary($4);
-   }
- | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions 'CURSOR'
-   {
-     parser.addTablePrimary($4);
-     if (!$5) {
-       parser.suggestKeywords(['ADD PARTITIONS', 'DROP PARTITIONS', 'SYNC PARTITIONS']);
-     }
-   }
- ;
-
-OptionalRepair
- :
- | 'REPAIR'
- ;
-
-OptionalAddDropSyncPartitions
- :
- | AddDropOrSync 'PARTITIONS'
- ;
-
-AddDropSyncPartitions_EDIT
- : AddDropOrSync 'CURSOR'
-   {
-     parser.suggestKeywords(['PARTITIONS']);
-   }
- ;
-
-AddDropOrSync
- : 'ADD'
- | 'DROP'
- | 'SYNC'
- ;
-
-ReloadFunction
- : 'RELOAD' 'FUNCTION'
- ;
-
-ReloadFunction_EDIT
- : 'RELOAD' 'CURSOR'
-   {
-     parser.suggestKeywords(['FUNCTION']);
-   }
- ;
-
-NullableComment
- : QuotedValue
- | 'NULL'
- ;

+ 0 - 29
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_create.jison

@@ -618,35 +618,6 @@ ConstraintList_EDIT
  | ConstraintList ',' TableConstraint_EDIT
  ;
 
-TableConstraint
- : TableConstraintLeftPart OptionalDisable OptionalNovalidate OptionalRelyOrNorely
- ;
-
-TableConstraint_EDIT
- : TableConstraintLeftPart_EDIT OptionalDisable OptionalNovalidate OptionalRelyOrNorely
- | TableConstraintLeftPart OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
-   {
-     parser.suggestKeywordsForOptionalsLR([$4, $3, $2], [
-       [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
-       { value: 'NOVALIDATE', weight: 2 },
-       { value: 'DISABLE', weight: 3 }
-     ]);
-   }
- ;
-
-TableConstraintLeftPart
- : 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
- | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CHECK' '(' ValueExpression ')'
- | 'CONSTRAINT' RegularOrBacktickedIdentifier 'UNIQUE' ParenthesizedColumnList
- ;
-
-TableConstraintLeftPart_EDIT
- : 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['CHECK', 'FOREIGN KEY', 'UNIQUE']);
-   }
- | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
- ;
 PrimaryKeySpecification
  : PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely
  ;

+ 0 - 348
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_drop.jison

@@ -1,348 +0,0 @@
-// 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
- : DropStatement
- | AbortStatement
- ;
-
-DataDefinition_EDIT
- : DropStatement_EDIT
- | AbortStatement_EDIT
- ;
-
-DataManipulation
- : DeleteStatement
- ;
-
-DataManipulation_EDIT
- : DeleteStatement_EDIT
- ;
-
-DropStatement
- : DropDatabaseStatement
- | DropFunctionStatement
- | DropRoleStatement
- | DropTableStatement
- | DropIndexStatement
- | DropMacroStatement
- | DropMaterializedViewStatement
- | DropViewStatement
- | TruncateTableStatement
- ;
-
-DropStatement_EDIT
- : DropDatabaseStatement_EDIT
- | DropFunctionStatement_EDIT
- | DropTableStatement_EDIT
- | DropIndexStatement_EDIT
- | DropMacroStatement_EDIT
- | DropMaterializedViewStatement_EDIT
- | DropViewStatement_EDIT
- | TruncateTableStatement_EDIT
- | 'DROP' 'CURSOR'
-   {
-     parser.suggestKeywords(['DATABASE', 'FUNCTION', 'INDEX', 'MATERIALIZED VIEW', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'VIEW']);
-   }
- ;
-
-DropDatabaseStatement
- : 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
- ;
-
-DropDatabaseStatement_EDIT
- : 'DROP' DatabaseOrSchema OptionalIfExists
- | 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
- | 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-     parser.suggestDatabases();
-   }
- | 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['CASCADE', 'RESTRICT']);
-   }
- | 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
- | 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascadeOrRestrict
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- ;
-
-DropFunctionStatement
- : 'DROP' 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier
- | 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists RegularIdentifier
- ;
-
-DropFunctionStatement_EDIT
- : 'DROP' 'FUNCTION' OptionalIfExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- | 'DROP' 'FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- | 'DROP' 'FUNCTION' OptionalIfExists_EDIT
- | 'DROP' 'FUNCTION' OptionalIfExists_EDIT SchemaQualifiedIdentifier
- | 'DROP' 'FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT
- | 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- | 'DROP' 'TEMPORARY' 'FUNCTION' OptionalIfExists_EDIT
- ;
-
-DropRoleStatement
- : 'DROP' 'ROLE' RegularIdentifier
- ;
-
-DropTableStatement
- : 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-DropTableStatement_EDIT
- : 'DROP' 'TABLE' OptionalIfExists_EDIT
- | 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyTables = true;
-     }
-   }
- | 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
- | 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
-   {
-     parser.addTablePrimary($4);
-     if (!$5) {
-       parser.suggestKeywords(['PURGE']);
-     }
-   }
- ;
-
-OptionalPurge
- :
- | 'PURGE'
- ;
-
-DropIndexStatement
- : 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($6);
-   }
- ;
-
-DropIndexStatement_EDIT
- : 'DROP' 'INDEX' OptionalIfExists 'CURSOR'
-   {
-     parser.suggestKeywords(['IF EXISTS']);
-   }
- | 'DROP' 'INDEX' OptionalIfExists_EDIT
- | 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'DROP' 'INDEX' OptionalIfExists RegularOrBacktickedIdentifier 'ON' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-DropMacroStatement
- : 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists RegularIdentifier
- ;
-
-DropMacroStatement_EDIT
- : 'DROP' 'TEMPORARY' 'CURSOR'
-   {
-     parser.suggestKeywords(['FUNCTION', 'MACRO']);
-   }
- | 'DROP' 'TEMPORARY' 'MACRO' OptionalIfExists 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- | '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
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-DropViewStatement_EDIT
- : 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-     parser.suggestTables({ onlyViews: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($5);
-     if (!$3) {
-       parser.suggestKeywords(['IF EXISTS']);
-     }
-   }
- | 'DROP' 'VIEW' OptionalIfExists_EDIT
- | 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($4);
-   }
- | 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- ;
-
-TruncateTableStatement
- : 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-TruncateTableStatement_EDIT
- : 'TRUNCATE' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'TRUNCATE' 'TABLE' 'CURSOR' OptionalPartitionSpec
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
- | 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       parser.suggestKeywords(['PARTITION']);
-     }
-   }
- | 'TRUNCATE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- | 'TRUNCATE' 'TABLE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-DeleteStatement
- : 'DELETE' 'FROM' SchemaQualifiedTableIdentifier OptionalWhereClause
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-DeleteStatement_EDIT
- : 'DELETE' 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | 'DELETE' 'FROM' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'DELETE' 'FROM' SchemaQualifiedTableIdentifier 'CURSOR' OptionalWhereClause
-   {
-     parser.addTablePrimary($3);
-     if (!$5) {
-       parser.suggestKeywords(['WHERE']);
-     }
-   }
- | 'DELETE' 'FROM' SchemaQualifiedTableIdentifier_EDIT OptionalWhereClause
- | 'DELETE' 'FROM' SchemaQualifiedTableIdentifier WhereClause_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AbortStatement
- : 'ABORT' 'TRANSACTIONS' TransactionIdList
- ;
-
-AbortStatement_EDIT
- : 'ABORT' 'CURSOR'
-   {
-     parser.suggestKeywords(['TRANSACTIONS']);
-   }
- ;
-
-TransactionIdList
- : UnsignedNumericLiteral
- | TransactionIdList ',' UnsignedNumericLiteral
- ;

+ 86 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_msck.jison

@@ -0,0 +1,86 @@
+// 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
+ : Msck
+ ;
+
+DataDefinition_EDIT
+ : Msck_EDIT
+ ;
+
+Msck
+ : 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions
+   {
+     parser.addTablePrimary($4);
+   }
+ ;
+
+Msck_EDIT
+ : 'MSCK' OptionalRepair 'CURSOR'
+   {
+     if (!$2) {
+       parser.suggestKeywords(['TABLE', 'REPAIR TABLE']);
+     } else {
+       parser.suggestKeywords(['TABLE']);
+     }
+   }
+ | 'MSCK' OptionalRepair 'TABLE' 'CURSOR'
+   {
+     parser.suggestTables({ onlyTables: true });
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier AddDropSyncPartitions_EDIT
+   {
+     parser.addTablePrimary($4);
+   }
+ | 'MSCK' OptionalRepair 'TABLE' SchemaQualifiedTableIdentifier OptionalAddDropSyncPartitions 'CURSOR'
+   {
+     parser.addTablePrimary($4);
+     if (!$5) {
+       parser.suggestKeywords(['ADD PARTITIONS', 'DROP PARTITIONS', 'SYNC PARTITIONS']);
+     }
+   }
+ ;
+
+OptionalRepair
+ :
+ | 'REPAIR'
+ ;
+
+OptionalAddDropSyncPartitions
+ :
+ | AddDropOrSync 'PARTITIONS'
+ ;
+
+AddDropSyncPartitions_EDIT
+ : AddDropOrSync 'CURSOR'
+   {
+     parser.suggestKeywords(['PARTITIONS']);
+   }
+ ;
+
+AddDropOrSync
+ : 'ADD'
+ | 'DROP'
+ | 'SYNC'
+ ;

+ 0 - 535
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_show.jison

@@ -1,535 +0,0 @@
-// 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
- : ShowStatement
- ;
-
-DataDefinition_EDIT
- : ShowStatement_EDIT
- ;
-
-ShowStatement
- : ShowColumnsStatement
- | ShowCompactionsStatement
- | ShowConfStatement
- | ShowCreateTableStatement
- | ShowCurrentRolesStatement
- | ShowDatabasesStatement
- | ShowFunctionsStatement
- | ShowGrantStatement
- | ShowIndexStatement
- | ShowLocksStatement
- | ShowMaterializedViewsStatement
- | ShowPartitionsStatement
- | ShowRolesStatement
- | ShowRoleStatement
- | ShowTablesStatement
- | ShowTableStatement
- | ShowTblPropertiesStatement
- | ShowTransactionsStatement
- | ShowViewsStatement
- ;
-
-ShowStatement_EDIT
- : 'SHOW' 'CURSOR'
-   {
-     parser.suggestKeywords(['COLUMNS', 'COMPACTIONS', 'CONF', 'CREATE TABLE', 'CURRENT ROLES', 'DATABASES', 'FORMATTED', 'FUNCTIONS', 'GRANT', 'INDEX', 'INDEXES', 'LOCKS', 'MATERIALIZED VIEWS', 'PARTITIONS', 'PRINCIPALS', 'ROLE GRANT', 'ROLES', 'SCHEMAS', 'TABLE EXTENDED', 'TABLES', 'TBLPROPERTIES', 'TRANSACTIONS', 'VIEWS']);
-   }
- | 'SHOW' 'CURSOR' RegularOrBackTickedSchemaQualifiedName
-   {
-     // ROLES is considered a non-reserved keywords so we can't match it in ShowCurrentRolesStatement_EDIT
-     if ($3.identifierChain && $3.identifierChain.length === 1 && $3.identifierChain[0].name.toLowerCase() === 'roles') {
-       parser.suggestKeywords(['CURRENT']);
-       parser.yy.locations.pop();
-     } else {
-       parser.addTablePrimary($3);
-     }
-   }
- | 'SHOW' 'CURSOR' LIKE SingleQuotedValue
-   {
-     parser.suggestKeywords(['DATABASES', 'SCHEMAS', 'TABLE EXTENDED']);
-   }
- | ShowColumnsStatement_EDIT
- | ShowCreateTableStatement_EDIT
- | ShowCurrentRolesStatement_EDIT
- | ShowDatabasesStatement_EDIT
- | ShowGrantStatement_EDIT
- | ShowIndexStatement_EDIT
- | ShowLocksStatement_EDIT
- | ShowMaterializedViewsStatement_EDIT
- | ShowPartitionsStatement_EDIT
- | ShowRoleStatement_EDIT
- | ShowTablesStatement_EDIT
- | ShowTableStatement_EDIT
- | ShowTblPropertiesStatement_EDIT
- | ShowViewsStatement_EDIT
- ;
-
-ShowColumnsStatement
- : 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier
- | 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- ;
-
-ShowColumnsStatement_EDIT
- : 'SHOW' 'COLUMNS' 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' 'COLUMNS' 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' 'COLUMNS' FromOrIn 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | 'SHOW' 'COLUMNS' FromOrIn 'CURSOR' FromOrIn
-   {
-     parser.suggestTables();
-   }
- | 'SHOW' 'COLUMNS' FromOrIn 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
-   {
-     parser.suggestTables();
-   }
- | 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' 'COLUMNS' FromOrIn RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-ShowCompactionsStatement
- : 'SHOW' 'COMPACTIONS'
- ;
-
-ShowConfStatement
- : 'SHOW' 'CONF' ConfigurationName
- ;
-
-ShowCreateTableStatement
- : 'SHOW' 'CREATE' TableOrView RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($4);
-   }
- ;
-
-ShowCreateTableStatement_EDIT
- : 'SHOW' 'CREATE' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'SHOW' 'CREATE' TableOrView 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | 'SHOW' 'CREATE' TableOrView RegularOrBackTickedSchemaQualifiedName_EDIT
-   {
-     if (parser.yy.result.suggestTables && $3.isView) {
-       parser.yy.result.suggestTables.onlyViews = true;
-     }
-   }
- | 'SHOW' 'CREATE' 'CURSOR' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($4);
-     parser.suggestKeywords(['TABLE']);
-   }
- ;
-
-TableOrView
- : 'TABLE'
- | 'VIEW'   -> { isView: true }
- ;
-
-ShowCurrentRolesStatement
- : 'SHOW' 'CURRENT' 'ROLES'
- ;
-
-ShowCurrentRolesStatement_EDIT
- : 'SHOW' 'CURRENT' 'CURSOR'
-   {
-     parser.suggestKeywords([ 'ROLES' ]);
-   }
- ;
-
-ShowDatabasesStatement
- : 'SHOW' DatabasesOrSchemas 'LIKE' SingleQuotedValue
- ;
-
-ShowDatabasesStatement_EDIT
- : 'SHOW' DatabasesOrSchemas 'CURSOR'
-   {
-     parser.suggestKeywords(['LIKE']);
-   }
- ;
-
-ShowFunctionsStatement
- : 'SHOW' 'FUNCTIONS'
- | 'SHOW' 'FUNCTIONS' DoubleQuotedValue
- ;
-
-ShowGrantStatement
- : 'SHOW' 'GRANT' OptionalPrincipalName
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'ALL'
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'TABLE' SchemaQualifiedTableIdentifier
- ;
-
-ShowGrantStatement_EDIT
- : 'SHOW' 'GRANT' OptionalPrincipalName_EDIT
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'SHOW' 'GRANT' OptionalPrincipalName_EDIT 'ON' 'ALL'
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'TABLE']);
-     parser.suggestTables();
-   }
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' SchemaQualifiedTableIdentifier_EDIT
- | 'SHOW'  'GRANT' OptionalPrincipalName 'ON' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'SHOW' 'GRANT' OptionalPrincipalName 'ON' 'CURSOR' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-OptionalPrincipalName
- :
- | RegularIdentifier
- ;
-
-OptionalPrincipalName_EDIT
- : 'CURSOR'
- | RegularIdentifier 'CURSOR'
- ;
-
-ShowIndexStatement
- : 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier
- | 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- ;
-
-ShowIndexStatement_EDIT
- : 'SHOW' OptionallyFormattedIndex
- | 'SHOW' OptionallyFormattedIndex_EDIT
- | 'SHOW' OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier
- | 'SHOW' OptionallyFormattedIndex_EDIT 'ON' RegularOrBacktickedIdentifier FromOrIn RegularOrBacktickedIdentifier
- | 'SHOW' OptionallyFormattedIndex 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'SHOW' OptionallyFormattedIndex 'ON' 'CURSOR'
-   {
-     parser.suggestTables();
-   }
- | 'SHOW' OptionallyFormattedIndex 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier 'CURSOR' RegularOrBacktickedIdentifier
-   {
-     parser.suggestKeywords(['FROM', 'IN']);
-   }
- | 'SHOW' OptionallyFormattedIndex 'ON' RegularOrBacktickedIdentifier FromOrIn 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'SHOW' OptionallyFormattedIndex 'ON' 'CURSOR' FromOrIn RegularOrBacktickedIdentifier
-   {
-     parser.suggestTables({identifierChain: [{name: $6}]});
-   }
- ;
-
-ShowMaterializedViewsStatement
- : 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike
- ;
-
-ShowMaterializedViewsStatement_EDIT
- : 'SHOW' 'MATERIALIZED' 'CURSOR'
-   {
-     parser.suggestKeywords(['VIEWS']);
-   }
- | 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
-   {
-     if (!$5 && !$4) {
-       parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
-     } else if (!$5) {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- | 'SHOW' 'MATERIALIZED' 'VIEWS' InOrFromDatabase_EDIT OptionalLike
- | 'SHOW' 'MATERIALIZED' 'VIEWS' OptionalInOrFromDatabase Like_EDIT
- ;
-
-ShowLocksStatement
- : 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName 'EXTENDED'
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec 'EXTENDED'
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'LOCKS' DatabaseOrSchema RegularOrBacktickedIdentifier
- ;
-
-ShowLocksStatement_EDIT
- : 'SHOW' 'LOCKS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-     parser.suggestKeywords(['DATABASE', 'SCHEMA']);
-   }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
-    {
-      parser.addTablePrimary($3);
-      parser.suggestKeywords(['EXTENDED', 'PARTITION']);
-    }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT 'EXTENDED'
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName PartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | 'SHOW' 'LOCKS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec 'EXTENDED'
- | 'SHOW' 'LOCKS' DatabaseOrSchema 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-ShowPartitionsStatement
- : 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName PartitionSpec
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ShowPartitionsStatement_EDIT
- : 'SHOW' 'PARTITIONS' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- | 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT
- | 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['PARTITION']);
-   }
- | 'SHOW' 'PARTITIONS' RegularOrBackTickedSchemaQualifiedName_EDIT PartitionSpec
- ;
-
-ShowRoleStatement
- : 'SHOW' 'ROLE' 'GRANT' RoleOrUser RegularIdentifier
- ;
-
-ShowRoleStatement_EDIT
- : 'SHOW' 'ROLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['GRANT']);
-   }
- | 'SHOW' 'ROLE' 'CURSOR' RoleOrUser RegularIdentifier
-   {
-     parser.suggestKeywords(['GRANT']);
-   }
- | 'SHOW' 'ROLE' 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE', 'USER']);
-   }
- | 'SHOW' 'ROLE' 'GRANT' 'CURSOR' RegularIdentifier
-   {
-     parser.suggestKeywords(['ROLE', 'USER']);
-   }
- ;
-
-ShowRolesStatement
- : 'SHOW' 'ROLES'
- ;
-
-ShowTableStatement
- : 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
- ;
-
-ShowTableStatement_EDIT
- : 'SHOW' 'TABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR'
-    {
-      if ($4) {
-        parser.suggestKeywords(['LIKE']);
-      } else {
-        parser.suggestKeywords(['FROM', 'IN', 'LIKE']);
-      }
-    }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue
- | 'SHOW' 'TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue
-    {
-      parser.suggestKeywords(['EXTENDED']);
-    }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue
-    {
-      parser.suggestKeywords(['LIKE']);
-    }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR'
-    {
-      parser.suggestKeywords(['PARTITION']);
-    }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase_EDIT 'LIKE' SingleQuotedValue PartitionSpec
- | 'SHOW' 'TABLE' 'CURSOR' OptionalFromDatabase 'LIKE' SingleQuotedValue PartitionSpec
-   {
-     parser.suggestKeywords(['EXTENDED']);
-   }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'CURSOR' SingleQuotedValue PartitionSpec
-   {
-     parser.suggestKeywords(['LIKE']);
-   }
- | 'SHOW' 'TABLE' 'EXTENDED' OptionalFromDatabase 'LIKE' SingleQuotedValue 'CURSOR' PartitionSpecList
-   {
-     parser.suggestKeywords(['PARTITION']);
-   }
- ;
-
-ShowTablesStatement
- : 'SHOW' 'TABLES' OptionalInDatabase
- | 'SHOW' 'TABLES' OptionalInDatabase SingleQuotedValue
- | 'SHOW' 'TABLES' OptionalInDatabase 'LIKE' SingleQuotedValue
- ;
-
-ShowTablesStatement_EDIT
- : 'SHOW' 'TABLES' OptionalInDatabase 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IN', 'LIKE']);
-     } else {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- ;
-
-ShowTblPropertiesStatement
- : 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName
-   {
-     parser.addTablePrimary($3);
-   }
- | 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName '(' QuotedValue ')'
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-ShowTblPropertiesStatement_EDIT
- : 'SHOW' 'TBLPROPERTIES' RegularOrBackTickedSchemaQualifiedName_EDIT
- | 'SHOW' 'TBLPROPERTIES' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ prependDot: true });
-   }
- ;
-
-ShowTransactionsStatement
- : 'SHOW' 'TRANSACTIONS'
- ;
-
-ShowViewsStatement
- : 'SHOW' 'VIEWS' OptionalInOrFromDatabase OptionalLike
- ;
-
-ShowViewsStatement_EDIT
- : 'SHOW' 'VIEWS' OptionalInOrFromDatabase OptionalLike 'CURSOR'
-   {
-     if (!$4 && !$3) {
-       parser.suggestKeywords([{ value: 'IN', weight: 2 }, { value: 'FROM', weight: 2 }, { value: 'LIKE', weight: 1 }]);
-     } else if (!$4) {
-       parser.suggestKeywords(['LIKE']);
-     }
-   }
- | 'SHOW' 'VIEWS' InOrFromDatabase_EDIT OptionalLike
- | 'SHOW' 'VIEWS' OptionalInOrFromDatabase Like_EDIT
- ;
-
-OptionalInOrFromDatabase
- :
- | 'IN' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@2, [ { name: $2 } ]);
-   }
- | 'FROM' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@2, [ { name: $2 } ]);
-   }
- ;
-
-InOrFromDatabase_EDIT
- : 'IN' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'FROM' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-OptionalLike
- :
- | 'LIKE' SingleQuotedValue
- ;
-
-Like_EDIT
- : 'LIKE' 'CURSOR'
- ;

+ 16 - 6
desktop/core/src/desktop/js/parse/jison/sql/hive/structure.json

@@ -2,17 +2,22 @@
   "lexer": "sql.jisonlex",
   "autocomplete": [
     "../generic/autocomplete_header.jison",
-    "sql_alter.jison",
+    "common/sql_table_constraint.jison",
+    "alter/sql_alter.jison",
+    "alter/sql_alter_materialized_view.jison",
     "sql_analyze.jison",
     "sql_create.jison",
-    "sql_drop.jison",
+    "drop/sql_drop.jison",
+    "drop/sql_drop_materialized_view.jison",
     "sql_error.jison",
     "sql_grant.jison",
     "sql_insert.jison",
     "sql_load.jison",
     "sql_main.jison",
+    "sql_msck.jison",
     "sql_set.jison",
-    "sql_show.jison",
+    "show/sql_show.jison",
+    "show/sql_show_materialized_views.jison",
     "sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",
@@ -20,16 +25,21 @@
   ],
   "syntax": [
     "../generic/syntax_header.jison",
-    "sql_alter.jison",
+    "common/sql_table_constraint.jison",
+    "alter/sql_alter.jison",
+    "alter/sql_alter_materialized_view.jison",
     "sql_analyze.jison",
     "sql_create.jison",
-    "sql_drop.jison",
+    "drop/sql_drop.jison",
+    "drop/sql_drop_materialized_view.jison",
     "sql_grant.jison",
     "sql_insert.jison",
     "sql_load.jison",
     "sql_main.jison",
+    "sql_msck.jison",
     "sql_set.jison",
-    "sql_show.jison",
+    "show/sql_show.jison",
+    "show/sql_show_materialized_views.jison",
     "sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",

+ 27 - 0
desktop/core/src/desktop/js/parse/jison/sql/presto/common/table_constraint.jison

@@ -0,0 +1,27 @@
+// 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.
+
+TableConstraint
+ : 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ ;
+
+TableConstraint_EDIT
+ : 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['FOREIGN KEY']);
+   }
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
+ ;

+ 0 - 378
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_grant.jison

@@ -1,378 +0,0 @@
-// 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
- : GrantStatement
- | RevokeStatement
- ;
-
-DataDefinition_EDIT
- : GrantStatement_EDIT
- | RevokeStatement_EDIT
- ;
-
-GrantStatement
- : 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption
- | 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
- | 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption
- ;
-
-GrantStatement_EDIT
- : 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
-   }
- | 'GRANT' PrivilegeTypeList_EDIT OptionalOnSpecification
- | 'GRANT' PrivilegeTypeList OnSpecification_EDIT
- | 'GRANT' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['ON', 'TO']);
-     } else {
-       parser.suggestKeywords(['TO']);
-     }
-   }
- | 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList_EDIT
- | 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList OptionalWithGrantOption 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['WITH GRANT OPTION']);
-     }
-   }
- | 'GRANT' PrivilegeTypeList OptionalOnSpecification 'TO' PrincipalSpecificationList WithGrantOption_EDIT
- | 'GRANT' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['TO']);
-   }
- | 'GRANT' UserOrRoleList 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
- | 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
-   {
-     if (!$5) {
-       parser.suggestKeywords(['WITH ADMIN OPTION']);
-     }
-   }
- | 'GRANT' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
- | 'GRANT' 'ROLE' UserOrRoleList 'TO' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList_EDIT
- | 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList OptionalWithAdminOption 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['WITH ADMIN OPTION']);
-     }
-   }
- | 'GRANT' 'ROLE' UserOrRoleList 'TO' PrincipalSpecificationList WithAdminOption_EDIT
- ;
-
-OptionalOnSpecification
- :
- | 'ON' ObjectSpecification
- ;
-
-OnSpecification_EDIT
- : 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['DATABASE', 'TABLE']);
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'ON' ObjectSpecification_EDIT
- ;
-
-ObjectSpecification
- : 'DATABASE' RegularOrBacktickedIdentifier
- | 'TABLE' SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($2);
-   }
- | SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-ObjectSpecification_EDIT
- : 'DATABASE' 'CURSOR'
-   {
-     parser.suggestDatabases();
-   }
- | 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'TABLE' SchemaQualifiedTableIdentifier_EDIT
- | SchemaQualifiedTableIdentifier_EDIT
- ;
-
-PrivilegeTypeList
- : PrivilegeTypeWithOptionalColumn
-   {
-     if ($1.toUpperCase() === 'ALL') {
-       $$ = { singleAll: true };
-     }
-   }
- | PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn
- ;
-
-PrivilegeTypeList_EDIT
- : PrivilegeTypeWithOptionalColumn_EDIT
- | PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn_EDIT
- | PrivilegeTypeWithOptionalColumn_EDIT ',' PrivilegeTypeList
- | PrivilegeTypeList ',' PrivilegeTypeWithOptionalColumn_EDIT ',' PrivilegeTypeList
- | 'CURSOR' ',' PrivilegeTypeList
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | PrivilegeTypeList ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | PrivilegeTypeList ',' 'CURSOR' ',' PrivilegeTypeList
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- ;
-
-PrivilegeTypeWithOptionalColumn
- : PrivilegeType OptionalParenthesizedColumnList
- ;
-
-PrivilegeTypeWithOptionalColumn_EDIT
- : PrivilegeType ParenthesizedColumnList_EDIT
- ;
-
-PrivilegeType
- : 'ALL'
- | 'ALTER'
- | 'CREATE'
- | 'DELETE'
- | 'DROP'
- | 'INDEX'
- | 'INSERT'
- | 'LOCK'
- | 'SELECT'
- | 'SHOW_DATABASE'
- | 'UPDATE'
- ;
-
-PrincipalSpecificationList
- : PrincipalSpecification
- | PrincipalSpecificationList ',' PrincipalSpecification
- ;
-
-PrincipalSpecificationList_EDIT
- : PrincipalSpecificationList ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'CURSOR' ',' PrincipalSpecificationList
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | PrincipalSpecificationList ',' 'CURSOR' ',' PrincipalSpecificationList
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- ;
-
-PrincipalSpecification
- : 'USER' RegularOrBacktickedIdentifier
- | 'GROUP' RegularOrBacktickedIdentifier
- | 'ROLE' RegularOrBacktickedIdentifier
- ;
-
-PrincipalSpecification_EDIT
- : 'USER' 'CURSOR'
- | 'GROUP' 'CURSOR'
- | 'ROLE' 'CURSOR'
- ;
-
-UserOrRoleList
- : RegularOrBacktickedIdentifier
- | UserOrRoleList ',' RegularOrBacktickedIdentifier
- ;
-
-OptionalWithGrantOption
- :
- | 'WITH' 'GRANT' 'OPTION'
- ;
-
-WithGrantOption_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['GRANT OPTION']);
-   }
- | 'WITH' 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;
-
-OptionalWithAdminOption
- :
- | 'WITH' 'ADMIN' 'OPTION'
- ;
-
-WithAdminOption_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['ADMIN OPTION']);
-   }
- | 'WITH' 'ADMIN' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;
-
-RevokeStatement
- : 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList
- | 'REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | 'REVOKE' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' PrincipalSpecificationList
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList
- | 'REVOKE' 'ALL' PrivilegesOrGrantOption 'FROM' UserOrRoleList
- ;
-
-RevokeStatement_EDIT
- : 'REVOKE' 'CURSOR'
-   {
-     parser.suggestKeywords(['ADMIN OPTION FOR', 'ALL', 'ALL GRANT OPTION FROM', 'ALL PRIVILEGES FROM', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'GRANT OPTION FOR', 'INDEX', 'INSERT', 'LOCK', 'ROLE', 'SELECT', 'UPDATE']);
-   }
- | 'REVOKE' PrivilegeTypeList_EDIT
- | 'REVOKE' PrivilegeTypeList OnSpecification_EDIT
- | 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$3) {
-       if ($2.singleAll) {
-         parser.suggestKeywords(['FROM', 'GRANT OPTION', 'ON', 'PRIVILEGES FROM']);
-       } else {
-         parser.suggestKeywords(['FROM', 'ON']);
-       }
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
- | 'REVOKE' 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION FOR']);
-   }
- | 'REVOKE' 'GRANT' 'OPTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['FOR']);
-   }
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'ALTER', 'CREATE', 'DELETE', 'DROP', 'INDEX', 'INSERT', 'LOCK', 'SELECT', 'SHOW_DATABASE', 'UPDATE']);
-   }
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList_EDIT
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OnSpecification_EDIT
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['FROM', 'ON']);
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' 'GRANT' 'OPTION' 'FOR' PrivilegeTypeList OptionalOnSpecification 'FROM' PrincipalSpecificationList_EDIT
- | 'REVOKE' UserOrRoleList 'CURSOR'
-   {
-     if ($2.toUpperCase() === 'ADMIN') {
-       parser.suggestKeywords(['FROM', 'OPTION FOR']);
-     } else {
-       parser.suggestKeywords(['FROM']);
-     }
-   }
- | 'REVOKE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | 'REVOKE' 'ROLE' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | 'REVOKE' 'ROLE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
-
- | 'REVOKE' 'ADMIN' 'OPTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['FOR']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROLE']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' 'CURSOR'
-   {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
-   }
- | 'REVOKE' 'ADMIN' 'OPTION' 'FOR' 'ROLE' UserOrRoleList 'FROM' PrincipalSpecificationList_EDIT
- | 'REVOKE' 'ALL' PrivilegesOrGrantOption_EDIT
- | 'REVOKE' 'ALL' PrivilegesOrGrantOption 'CURSOR'
-   {
-     parser.suggestKeywords(['FROM']);
-   }
- ;
-
-PrivilegesOrGrantOption
- : 'PRIVILEGES'
- | 'GRANT' 'OPTION'
- ;
-
-PrivilegesOrGrantOption_EDIT
- : 'GRANT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OPTION']);
-   }
- ;

+ 0 - 536
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_insert.jison

@@ -1,536 +0,0 @@
-// 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.
-
-DataManipulation
- : InsertStatement
- | CommonTableExpression InsertStatement
- | MergeStatement
- ;
-
-DataManipulation_EDIT
- : InsertStatement_EDIT
- | CommonTableExpression InsertStatement_EDIT
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression_EDIT InsertStatement
- | MergeStatement_EDIT
- ;
-
-InsertStatement
- : InsertWithoutQuery
- | InsertWithoutQuery QuerySpecification
- | FromClause Inserts
- | FromClause SelectWithoutTableExpression OptionalSelectConditions
- ;
-
-InsertStatement_EDIT
- : InsertWithoutQuery_EDIT
- | InsertWithoutQuery 'CURSOR'
-   {
-     var keywords = [];
-     if ($1.suggestKeywords) {
-       keywords = parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]);
-     } else {
-       keywords = ['SELECT'];
-     }
-     if ($1.addValues) {
-       keywords.push({ weight: 1.1, value: 'VALUES' });
-     }
-     if (keywords.length > 0) {
-       parser.suggestKeywords(keywords);
-     }
-   }
- | InsertWithoutQuery_EDIT QuerySpecification
- | InsertWithoutQuery QuerySpecification_EDIT
- | FromClause Inserts_EDIT
-   {
-     if (!$2.keepTables) {
-       delete parser.yy.result.suggestTables;
-       delete parser.yy.result.suggestDatabases;
-     }
-   }
- | FromClause_EDIT
- | FromClause_EDIT Inserts
- | FromClause_EDIT SelectWithoutTableExpression OptionalSelectConditions
- | FromClause 'CURSOR'
-   {
-     parser.suggestKeywords(['INSERT INTO', 'INSERT OVERWRITE', 'SELECT']);
-   }
- | FromClause SelectWithoutTableExpression_EDIT OptionalSelectConditions
-   {
-     if ($2.cursorAtEnd) {
-       parser.checkForSelectListKeywords($2);
-       var keywords = parser.yy.result.suggestKeywords || [];
-       if ($3.suggestKeywords) {
-         keywords = keywords.concat($3.suggestKeywords);
-       }
-       if (keywords.length > 0) {
-         parser.suggestKeywords(keywords);
-       }
-     }
-     delete parser.yy.result.suggestTables;
-     delete parser.yy.result.suggestDatabases;
-   }
- | FromClause SelectWithoutTableExpression OptionalSelectConditions_EDIT
-   {
-     if ($3.cursorAtStart) {
-       parser.checkForSelectListKeywords($2.tableExpression);
-     }
-   }
- ;
-
-InsertWithoutQuery
- : 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec 'VALUES' InsertValuesList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-   }
- | 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (!$5 && !$6) {
-       $$ = { suggestKeywords: ['PARTITION'] }
-     } else if (!$6) {
-       $$ = { suggestKeywords: ['IF NOT EXISTS'] }
-     }
-   }
- | 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs
-   {
-     if (!$6 && !$7) {
-       $$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }, { value: 'STORED AS', weight: 1}] };
-     } else if (!$7) {
-       $$ = { suggestKeywords: ['STORED AS'] };
-     }
-   }
- | 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs
-    {
-      if (!$4 && !$5) {
-        $$ = { suggestKeywords: [{ value: 'ROW FORMAT', weight: 2 }, { value: 'STORED AS', weight: 1}] };
-      } else if (!$5) {
-        $$ = { suggestKeywords: ['STORED AS'] };
-      }
-    }
-  | 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (!$5 && !$6) {
-       $$ = { suggestKeywords: ['PARTITION'], addValues: true };
-     } else if (!$6) {
-       $$ = { addValues: true };
-     }
-   }
- ;
-
-InsertWithoutQuery_EDIT
- : 'INSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['OVERWRITE', 'INTO']);
-   }
- | 'INSERT' 'OVERWRITE' OptionalTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['DIRECTORY', 'LOCAL DIRECTORY', 'TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-     $$ = { keepTables: true }
-   }
- | 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $$ = { keepTables: true }
-   }
- | 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalIfNotExists
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- | 'INSERT' 'OVERWRITE' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalIfNotExists_EDIT
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-   }
- | 'INSERT' 'OVERWRITE' 'LOCAL' 'CURSOR'
-   {
-     parser.suggestKeywords(['DIRECTORY']);
-   }
- | 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat OptionalStoredAs
- | 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT OptionalStoredAs
- | 'INSERT' 'OVERWRITE' 'LOCAL' 'DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs_EDIT
- | 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath_EDIT OptionalInsertRowFormat OptionalStoredAs  // DIRECTORY is a non-reserved keyword
- | 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat_EDIT OptionalStoredAs
- | 'INSERT' 'OVERWRITE_DIRECTORY' HdfsPath OptionalInsertRowFormat OptionalStoredAs_EDIT
- | 'INSERT' 'INTO' OptionalTable 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['TABLE']);
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-     $$ = { keepTables: true }
-   }
- | 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec OptionalParenthesizedColumnList
-   {
-     $$ = { keepTables: true }
-   }
- | 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT OptionalParenthesizedColumnList
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- | 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier OptionalPartitionSpec OptionalParenthesizedColumnList_EDIT
-   {
-     $4.owner = 'insert';
-     parser.addTablePrimary($4);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.owner = 'insert';
-     }
-   }
- ;
-
-Inserts
- : GenericInsert
- | Inserts GenericInsert
- ;
-
-Inserts_EDIT
- : GenericInsert_EDIT
- | Inserts GenericInsert_EDIT
- | GenericInsert_EDIT Inserts
- | Inserts GenericInsert_EDIT Inserts
- ;
-
-// TODO: Verify unions in insert
-GenericInsert
- : InsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions
- ;
-
-GenericInsert_EDIT
- : InsertWithoutQuery_EDIT
- | InsertWithoutQuery_EDIT SelectWithoutTableExpression OptionalSelectConditions
- | InsertWithoutQuery 'CURSOR'
-   {
-     if ($1.suggestKeywords) {
-       parser.suggestKeywords(parser.createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'SELECT', weight: 1}]));
-     } else {
-       parser.suggestKeywords(['SELECT']);
-     }
-   }
- | InsertWithoutQuery SelectWithoutTableExpression_EDIT OptionalSelectConditions
-   {
-     if ($2.cursorAtEnd) {
-       parser.checkForSelectListKeywords($2);
-       var keywords = parser.yy.result.suggestKeywords || [];
-       if ($3.suggestKeywords) {
-         keywords = keywords.concat($3.suggestKeywords);
-       }
-       if (keywords.length > 0) {
-         parser.suggestKeywords(keywords);
-       }
-     }
-   }
- | InsertWithoutQuery SelectWithoutTableExpression OptionalSelectConditions_EDIT
- ;
-
-InsertValuesList
- : ParenthesizedRowValuesList
- | InsertValuesList ',' ParenthesizedRowValuesList
- ;
-
-ParenthesizedRowValuesList
- : '(' InValueList ')'
- ;
-
-OptionalTable
- :
- | 'TABLE'
- ;
-
-OptionalInsertRowFormat
- :
- | 'ROW' 'FORMAT' DelimitedRowFormat
- ;
-
-OptionalInsertRowFormat_EDIT
- : 'ROW' 'CURSOR'
-   {
-     parser.suggestKeywords(['FORMAT DELIMITED']);
-   }
- | 'ROW' 'FORMAT' 'CURSOR'
-   {
-     parser.suggestKeywords(['DELIMITED']);
-   }
- | 'ROW' 'FORMAT' DelimitedRowFormat_EDIT
- ;
-
-SelectWithoutTableExpression
- : 'SELECT' OptionalAllOrDistinct SelectList  -> { selectList: $3 }
- ;
-
-SelectWithoutTableExpression_EDIT
- : 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR'
-   {
-     $$ = $3;
-     $$.cursorAtEnd = true;
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList_EDIT
-   {
-     parser.selectListNoTableSuggest($3, $2);
-   }
- | 'SELECT' OptionalAllOrDistinct 'CURSOR'
-   {
-     var keywords = parser.getSelectListKeywords();
-     if (!$2 || $2 === 'ALL') {
-       parser.suggestAggregateFunctions();
-       parser.suggestAnalyticFunctions();
-     }
-     if (!$2) {
-       keywords.push({ value: 'ALL', weight: 2 });
-       keywords.push({ value: 'DISTINCT', weight: 2 });
-     }
-     parser.suggestKeywords(keywords);
-     parser.suggestFunctions();
-     parser.suggestColumns();
-   }
- ;
-
-MergeStatement
- : MergeStatementLeftPart 'ON' ValueExpression WhenList
- ;
-
-MergeStatement_EDIT
- : MergeStatementLeftPart_EDIT
- | MergeStatementLeftPart 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | MergeStatementLeftPart 'ON' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- | MergeStatementLeftPart 'ON' ValueExpression_EDIT
- | MergeStatementLeftPart 'ON' ValueExpression 'CURSOR'
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'WHEN', weight: 2 }]);
-   }
- | MergeStatementLeftPart 'ON' ValueExpression WhenList_EDIT
- ;
-
-MergeStatementLeftPart
- : 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'AS' RegularIdentifier
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     if ($7.subQuery) {
-       parser.addTablePrimary({ subQueryAlias: $9 });
-     } else {
-       $7.alias = $9;
-     }
-   }
- ;
-
-MergeStatementLeftPart_EDIT
- : 'MERGE' 'CURSOR'
-   {
-     parser.suggestKeywords(['INTO']);
-   }
- | 'MERGE' 'INTO' 'CURSOR'
-   {
-     parser.suggestDatabases({ appendDot: true });
-     parser.suggestTables();
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier_EDIT
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['AS T USING']);
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['T USING']);
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['USING']);
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestDatabases({ appendDot: true });
-     parser.suggestTables();
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource_EDIT
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['AS S ON']);
-   }
- | 'MERGE' 'INTO' SchemaQualifiedTableIdentifier 'AS' RegularIdentifier 'USING' MergeSource 'AS' 'CURSOR'
-   {
-     $3.alias = $5;
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['S ON']);
-   }
- ;
-
-MergeSource
- : '(' TableSubQueryInner ')'  -> $2
- | SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-MergeSource_EDIT
- : '(' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | '(' TableSubQueryInner_EDIT RightParenthesisOrError
- | SchemaQualifiedTableIdentifier_EDIT
- ;
-
-WhenList
- : WhenClause
- | WhenClause WhenClause
- | WhenClause WhenClause WhenClause
- ;
-
-WhenList_EDIT
- : WhenClause_EDIT
-   {
-     if ($1.suggestThenKeywords) {
-       parser.suggestKeywords(['DELETE', 'INSERT VALUES', 'UPDATE SET']);
-     }
-   }
- | WhenClause 'CURSOR'
-   {
-     if (!$1.notPresent) {
-       parser.suggestKeywords(['WHEN']);
-     }
-   }
- | WhenClause WhenClause_EDIT
-  {
-     if (!$1.notPresent && $2.suggestThenKeywords) {
-       var keywords = [];
-       if (!$1.isDelete) {
-         keywords.push('DELETE');
-       }
-       if (!$1.isInsert) {
-         keywords.push('INSERT VALUES');
-       }
-       if (!$1.isUpdate) {
-         keywords.push('UPDATE SET');
-       }
-       parser.suggestKeywords(keywords);
-     }
-   }
- | WhenClause WhenClause 'CURSOR'
-   {
-     if (!$2.notPresent) {
-       parser.suggestKeywords(['WHEN']);
-     }
-   }
- | WhenClause WhenClause WhenClause_EDIT
-   {
-     if (!$2.notPresent && $3.suggestThenKeywords) {
-       var keywords = [];
-       if (!$1.isDelete && !$2.isDelete) {
-         keywords.push('DELETE');
-       }
-       if (!$1.isInsert && !$2.isInsert) {
-         keywords.push('INSERT VALUES');
-       }
-       if (!$1.isUpdate && !$2.isUpdate) {
-         keywords.push('UPDATE SET');
-       }
-       parser.suggestKeywords(keywords);
-     }
-   }
- ;
-
-WhenClause
- : 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert  -> { notPresent: !!$2, isDelete: $6.isDelete, isInsert: $6.isInsert, isUpdate: $6.isUpdate }
- ;
-
-WhenClause_EDIT
- : 'WHEN' OptionalNot 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestKeywords(['NOT MATCHED', 'MATCHED']);
-     } else {
-       parser.suggestKeywords(['MATCHED']);
-     }
-   }
- | 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['AND', 'THEN']);
-     } else {
-       parser.suggestValueExpressionKeywords($4, [{ value: 'THEN', weight: 2 }]);
-     }
-   }
- | 'WHEN' OptionalNot 'MATCHED' MatchCondition_EDIT
- | 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' 'CURSOR' -> { suggestThenKeywords: true }
- | 'WHEN' OptionalNot 'MATCHED' OptionalMatchCondition 'THEN' UpdateDeleteOrInsert_EDIT
- ;
-
-OptionalMatchCondition
- :
- | 'AND' ValueExpression -> $2
- ;
-
-MatchCondition_EDIT
- : 'AND' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- ;
-
-UpdateDeleteOrInsert
- : 'UPDATE' 'SET' SetClauseList        -> { isUpdate: true }
- | 'DELETE'                            -> { isDelete: true }
- | 'INSERT' 'VALUES' InsertValuesList  -> { isInsert: true }
- ;
-
-UpdateDeleteOrInsert_EDIT
- : 'UPDATE' 'CURSOR'
-   {
-     parser.suggestKeywords(['SET']);
-   }
- | 'UPDATE' 'SET' SetClauseList_EDIT
- | 'INSERT' 'CURSOR'
-   {
-     parser.suggestKeywords(['VALUES']);
-   }
- ;

+ 52 - 0
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_msck.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.
+
+DataDefinition
+ : Msck
+ ;
+
+DataDefinition_EDIT
+ : Msck_EDIT
+ ;
+
+Msck
+ : 'MSCK' 'REPAIR' 'TABLE' SchemaQualifiedTableIdentifier
+   {
+     parser.addTablePrimary($4);
+   }
+ ;
+
+Msck_EDIT
+ : 'MSCK' 'CURSOR'
+   {
+     parser.suggestKeywords(['REPAIR TABLE']);
+   }
+ | 'MSCK' 'REPAIR' 'CURSOR'
+   {
+     parser.suggestKeywords(['TABLE']);
+   }
+ | 'MSCK' 'REPAIR' 'TABLE' 'CURSOR'
+   {
+     parser.suggestTables({ onlyTables: true });
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'MSCK' 'REPAIR' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
+   {
+     if (parser.yy.result.suggestTables) {
+       parser.yy.result.suggestTables.onlyViews = true;
+     }
+   }
+ ;

+ 18 - 14
desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json

@@ -1,38 +1,42 @@
 {
   "lexer": "sql.jisonlex",
   "autocomplete": [
-    "../hive/autocomplete_header.jison",
-    "sql_alter.jison",
+    "../generic/autocomplete_header.jison",
+    "common/table_constraint.jison",
+    "../hive/alter/sql_alter.jison",
     "sql_analyze.jison",
     "sql_create.jison",
-    "sql_drop.jison",
+    "../hive/drop/sql_drop.jison",
     "../hive/sql_error.jison",
     "../hive/sql_grant.jison",
     "../hive/sql_insert.jison",
     "sql_load.jison",
     "sql_main.jison",
+    "sql_msck.jison",
     "../hive/sql_set.jison",
-    "sql_show.jison",
+    "../hive/show/sql_show.jison",
     "../hive/sql_update.jison",
-    "../hive/sql_use.jison",
-    "../hive/sql_valueExpression.jison",
-    "../hive/autocomplete_footer.jison"
+    "../generic/sql_use.jison",
+    "../generic/sql_valueExpression.jison",
+    "../generic/autocomplete_footer.jison"
   ],
   "syntax": [
-    "../hive/syntax_header.jison",
-    "sql_alter.jison",
+    "../generic/syntax_header.jison",
+    "common/table_constraint.jison",
+    "../hive/alter/sql_alter.jison",
     "sql_analyze.jison",
     "sql_create.jison",
-    "sql_drop.jison",
+    "../hive/drop/sql_drop.jison",
     "../hive/sql_grant.jison",
     "../hive/sql_insert.jison",
     "sql_load.jison",
     "sql_main.jison",
+    "sql_msck.jison",
     "../hive/sql_set.jison",
-    "sql_show.jison",
+    "../hive/show/sql_show.jison",
     "../hive/sql_update.jison",
-    "../hive/sql_use.jison",
-    "../hive/sql_valueExpression.jison",
-    "../hive/syntax_footer.jison"
+    "../generic/sql_use.jison",
+    "../generic/sql_valueExpression.jison",
+    "../generic/syntax_footer.jison"
   ]
 }

+ 2 - 20
desktop/core/src/desktop/js/parse/sql/druid/sqlParseSupport.js

@@ -19,6 +19,7 @@ import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
   getSubQuery,
+  suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1126,26 +1127,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 2 - 20
desktop/core/src/desktop/js/parse/sql/elasticsearch/sqlParseSupport.js

@@ -19,6 +19,7 @@ import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
   getSubQuery,
+  suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1126,26 +1127,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 2 - 21
desktop/core/src/desktop/js/parse/sql/flink/sqlParseSupport.js

@@ -18,7 +18,7 @@ import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
-  getSubQuery,
+  getSubQuery, suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1126,26 +1126,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 2 - 21
desktop/core/src/desktop/js/parse/sql/generic/sqlParseSupport.js

@@ -18,7 +18,7 @@ import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
-  getSubQuery,
+  getSubQuery, suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1126,26 +1126,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 7 - 0
desktop/core/src/desktop/js/parse/sql/hive/keywords.json

@@ -0,0 +1,7 @@
+{
+  "ALTER": ["DATABASE", "INDEX", "MATERIALIZED VIEW", "SCHEMA", "TABLE", "VIEW"],
+  "ALTER TABLE ADD CONSTRAINT identifier": ["CHECK", "FOREIGN KEY", "PRIMARY KEY", "UNIQUE"],
+  "DROP": ["DATABASE", "FUNCTION", "INDEX", "MATERIALIZED VIEW", "ROLE", "SCHEMA", "TABLE", "TEMPORARY FUNCTION", "TEMPORARY MACRO", "VIEW"],
+  "SHOW": [
+    "COLUMNS", "COMPACTIONS", "CONF", "CREATE TABLE", "CURRENT ROLES", "DATABASES", "FORMATTED", "FUNCTIONS", "GRANT", "INDEX", "INDEXES", "LOCKS", "MATERIALIZED VIEWS", "PARTITIONS", "PRINCIPALS", "ROLE GRANT", "ROLES", "SCHEMAS", "TABLE EXTENDED", "TABLES", "TBLPROPERTIES", "TRANSACTIONS", "VIEWS"]
+}

+ 5 - 21
desktop/core/src/desktop/js/parse/sql/hive/sqlParseSupport.js

@@ -14,9 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+import KEYWORDS from './keywords.json';
 import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
-import { applyTypeToSuggestions, getSubQuery } from 'parse/sql/sqlParseUtils';
+import { applyTypeToSuggestions, getSubQuery, suggestKeywords } from 'parse/sql/sqlParseUtils';
 
 const identifierEquals = (a, b) =>
   a &&
@@ -1291,26 +1292,9 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.KEYWORDS = KEYWORDS;
+
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

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

@@ -469,6 +469,17 @@ describe('hiveAutocompleteParser.js ALTER statements', () => {
       });
     });
 
+    it('should suggest keywords for "ALTER TABLE bar ADD CONSTRAINT boo |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar ADD CONSTRAINT boo ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['CHECK', 'FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE']
+        }
+      });
+    });
+
     it('should suggest keywords for "ALTER TABLE bar ADD CONSTRAINT boo FOREIGN |"', () => {
       assertAutoComplete({
         beforeCursor: 'ALTER TABLE bar ADD CONSTRAINT boo FOREIGN ',

+ 2 - 21
desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js

@@ -16,7 +16,7 @@
 
 import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
-import { applyTypeToSuggestions, getSubQuery } from 'parse/sql/sqlParseUtils';
+import {applyTypeToSuggestions, getSubQuery, suggestKeywords} from 'parse/sql/sqlParseUtils';
 
 const identifierEquals = (a, b) =>
   a &&
@@ -1367,26 +1367,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 2 - 21
desktop/core/src/desktop/js/parse/sql/ksql/sqlParseSupport.js

@@ -18,7 +18,7 @@ import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
-  getSubQuery,
+  getSubQuery, suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1121,26 +1121,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 2 - 21
desktop/core/src/desktop/js/parse/sql/phoenix/sqlParseSupport.js

@@ -18,7 +18,7 @@ import { matchesType } from 'sql/reference/typeUtils';
 import stringDistance from 'sql/stringDistance';
 import {
   applyTypeToSuggestions,
-  getSubQuery,
+  getSubQuery, suggestKeywords,
   valueExpressionSuggest
 } from 'parse/sql/sqlParseUtils';
 
@@ -1126,26 +1126,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 6 - 0
desktop/core/src/desktop/js/parse/sql/presto/keywords.json

@@ -0,0 +1,6 @@
+{
+  "ALTER": ["DATABASE", "INDEX", "SCHEMA", "TABLE", "VIEW"],
+  "ALTER TABLE ADD CONSTRAINT identifier": ["FOREIGN KEY", "PRIMARY KEY"],
+  "DROP": ["DATABASE", "FUNCTION", "INDEX", "ROLE", "SCHEMA", "TABLE", "TEMPORARY FUNCTION", "TEMPORARY MACRO", "VIEW"],
+  "SHOW": ["COLUMNS", "COMPACTIONS", "CONF", "CREATE TABLE", "CURRENT ROLES", "DATABASES", "FORMATTED", "FUNCTIONS", "GRANT", "INDEX", "INDEXES", "LOCKS", "PARTITIONS", "PRINCIPALS", "ROLE GRANT", "ROLES", "SCHEMAS", "TABLE EXTENDED", "TABLES", "TBLPROPERTIES", "TRANSACTIONS", "VIEWS"]
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js


+ 2 - 21
desktop/core/src/desktop/js/parse/sql/presto/sqlParseSupport.js

@@ -15,7 +15,7 @@
 // limitations under the License.
 
 import { matchesType } from 'sql/reference/typeUtils';
-import { applyTypeToSuggestions, getSubQuery } from 'parse/sql/sqlParseUtils';
+import {applyTypeToSuggestions, getSubQuery, suggestKeywords} from 'parse/sql/sqlParseUtils';
 
 /**
  * Calculates the Optimal String Alignment distance between two strings. Returns 0 when the strings are equal and the
@@ -1342,26 +1342,7 @@ const initSqlParser = function(parser) {
     return result;
   };
 
-  parser.suggestKeywords = function(keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
+  parser.suggestKeywords = suggestKeywords.bind(null, parser);
 
   parser.suggestColRefKeywords = function(colRefKeywords) {
     parser.yy.result.suggestColRefKeywords = colRefKeywords;

+ 25 - 0
desktop/core/src/desktop/js/parse/sql/sqlParseUtils.js

@@ -96,3 +96,28 @@ export const valueExpressionSuggest = (parser, oppositeValueExpression, operator
   }
   parser.suggestKeywords(keywords);
 };
+
+export const suggestKeywords = (parser, keywords) => {
+  if (typeof keywords === 'string') {
+    keywords = (parser.KEYWORDS && parser.KEYWORDS[keywords]) || [];
+  }
+
+  const weightedKeywords = [];
+  if (keywords.length === 0) {
+    return;
+  }
+  keywords.forEach(keyword => {
+    if (typeof keyword.weight !== 'undefined') {
+      weightedKeywords.push(keyword);
+    } else {
+      weightedKeywords.push({ value: keyword, weight: -1 });
+    }
+  });
+  weightedKeywords.sort((a, b) => {
+    if (a.weight !== b.weight) {
+      return b.weight - a.weight;
+    }
+    return a.value.localeCompare(b.value);
+  });
+  parser.yy.result.suggestKeywords = weightedKeywords;
+};

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott