فهرست منبع

HUE-9429 [editor] Extract and split CREATE for Hive and Presto

Johan Ahlen 5 سال پیش
والد
کامیت
afc9105efd
25فایلهای تغییر یافته به همراه2673 افزوده شده و 3254 حذف شده
  1. 4 4
      desktop/core/src/desktop/js/parse/jison/sql/hive/analyze/analyze_table.jison
  2. 29 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/common/table_constraint.jison
  3. 759 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_common.jison
  4. 100 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_database.jison
  5. 70 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_function.jison
  6. 193 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_index.jison
  7. 161 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_materialized_view.jison
  8. 23 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_role.jison
  9. 208 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_table.jison
  10. 34 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_temporary_function.jison
  11. 70 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_temporary_macro.jison
  12. 92 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_view.jison
  13. 119 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/explain/explain.jison
  14. 0 236
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_analyze.jison
  15. 0 1596
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_create.jison
  16. 26 6
      desktop/core/src/desktop/js/parse/jison/sql/hive/structure.json
  17. 46 0
      desktop/core/src/desktop/js/parse/jison/sql/presto/common/table_constraint.jison
  18. 698 0
      desktop/core/src/desktop/js/parse/jison/sql/presto/create/create_common.jison
  19. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/presto/create/create_database_no_db.jison
  20. 0 1408
      desktop/core/src/desktop/js/parse/jison/sql/presto/sql_create.jison
  21. 22 4
      desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json
  22. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js
  23. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js
  24. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js
  25. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js

+ 4 - 4
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_analyze.jison → desktop/core/src/desktop/js/parse/jison/sql/hive/analyze/analyze_table.jison

@@ -15,21 +15,21 @@
 // limitations under the License.
 
 DataDefinition
- : AnalyzeStatement
+ : AnalyzeTableStatement
  ;
 
 DataDefinition_EDIT
- : AnalyzeStatement_EDIT
+ : AnalyzeTableStatement_EDIT
  ;
 
-AnalyzeStatement
+AnalyzeTableStatement
  : 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
    {
      parser.addTablePrimary($3);
    }
  ;
 
-AnalyzeStatement_EDIT
+AnalyzeTableStatement_EDIT
  : 'ANALYZE' 'CURSOR'
    {
      parser.suggestKeywords(['TABLE']);

+ 29 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/common/sql_table_constraint.jison → desktop/core/src/desktop/js/parse/jison/sql/hive/common/table_constraint.jison

@@ -43,3 +43,32 @@ TableConstraintLeftPart_EDIT
    }
  | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
  ;
+
+ForeignKeySpecification
+ : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList
+   {
+     parser.addTablePrimary($5);
+   }
+ ;
+
+ForeignKeySpecification_EDIT
+ : 'FOREIGN' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEY']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList_EDIT
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'CURSOR'
+   {
+     parser.suggestKeywords(['REFERENCES']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' 'CURSOR'
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier_EDIT
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList_EDIT
+   {
+     parser.addTablePrimary($5);
+   }
+ ;

+ 759 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_common.jison

@@ -0,0 +1,759 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+DataDefinition_EDIT
+ : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'CURSOR'
+   {
+     if ($4) {
+       parser.suggestKeywords(['TABLE']);
+     } else {
+       if ($2 && !$3) {
+         parser.suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']);
+       } else if (!$2 && !$3) {
+         parser.suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'MATERIALIZED VIEW', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'TRANSACTIONAL TABLE', 'VIEW']);
+       } else if ($3) {
+         parser.suggestKeywords(['TABLE']);
+       }
+     }
+   }
+ ;
+
+OptionalComment
+ :
+ | Comment
+ ;
+
+Comment
+ : 'COMMENT' QuotedValue
+ ;
+
+ParenthesizedPropertyAssignmentList
+ : '(' PropertyAssignmentList ')'
+ ;
+
+PropertyAssignmentList
+ : PropertyAssignment
+ | PropertyAssignmentList ',' PropertyAssignment
+ ;
+
+PropertyAssignment
+ : QuotedValue '=' UnsignedValueSpecification
+ ;
+
+ParenthesizedColumnSpecificationList
+ : '(' ColumnSpecificationList ')'                              -> $2
+ | '(' ColumnSpecificationList ',' TableConstraints ')'  -> $2
+ ;
+
+ParenthesizedColumnSpecificationList_EDIT
+ : '(' ColumnSpecificationList_EDIT RightParenthesisOrError
+ | '(' ColumnSpecificationList ',' TableConstraints_EDIT RightParenthesisOrError
+ | '(' ColumnSpecificationList ',' 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords([{ value: 'PRIMARY KEY', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }]);
+   }
+ ;
+
+ColumnSpecificationList
+ : ColumnSpecification                              -> [$1]
+ | ColumnSpecificationList ',' ColumnSpecification  -> $1.concat($3)
+ ;
+
+ColumnSpecificationList_EDIT
+ : ColumnSpecification_EDIT
+ | ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecification 'CURSOR'
+   {
+     parser.checkForKeywords($1);
+   }
+ | ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
+   {
+     parser.checkForKeywords($1);
+   }
+ | ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
+   {
+     parser.checkForKeywords($3);
+   }
+ | ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
+   {
+     parser.checkForKeywords($3);
+   }
+ ;
+
+ColumnSpecification
+ : ColumnIdentifier ColumnDataType OptionalColumnOptions OptionalComment
+   {
+     $$ = $1;
+     $$.type = $2;
+     var keywords = [];
+     if (!$4) {
+       keywords = keywords.concat([
+         { value: 'COMMENT', weight: 1 },
+         { value: 'CHECK', weight: 2 },
+         { value: 'PRIMARY KEY', weight: 2 },
+         { value: 'UNIQUE', weight: 2 },
+         { value: 'NOT NULL', weight: 2 },
+         { value: 'DEFAULT', weight: 2 }
+       ]);
+       if (!$3 && $2.toLowerCase() === 'double') {
+         keywords.push({ value: 'PRECISION', weight: 3 });
+       } else if ($3 && $3.suggestKeywords) {
+         keywords = keywords.concat($3.suggestKeywords)
+       }
+     }
+     if (keywords.length > 0) {
+       $$.suggestKeywords = keywords;
+     }
+   }
+ ;
+
+ColumnSpecification_EDIT
+ : ColumnIdentifier 'CURSOR' OptionalColumnOptions OptionalComment
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions OptionalComment
+ ;
+
+OptionalColumnOptions
+ :
+ | ColumnOptions
+ ;
+
+ColumnOptions
+ : ColumnOption
+ | ColumnOptions ColumnOption
+ ;
+
+ColumnOption
+ : 'PRIMARY' 'KEY' ColumnOptionOptionals                  -> $3
+ | 'PRIMARY'                                              -> { suggestKeywords: [{ value: 'KEY', weight: 3 }] }
+ | 'UNIQUE' ColumnOptionOptionals                         -> $2
+ | 'NOT' 'NULL' ColumnOptionOptionals                     -> $3
+ | 'NOT'                                                  -> { suggestKeywords: [{ value: 'NULL', weight: 3 }] }
+ | 'DEFAULT' DefaultValue ColumnOptionOptionals           -> $3
+ | 'CHECK' '(' ValueExpression ')' ColumnOptionOptionals  -> $5
+ | 'DEFAULT'
+   {
+     $$ = {
+       suggestKeywords: [
+         { value: 'LITERAL', weight: 3 },
+         { value: 'CURRENT_USER()', weight: 3 },
+         { value: 'CURRENT_DATE()', weight: 3 },
+         { value: 'CURRENT_TIMESTAMP()', weight: 3 },
+         { value: 'NULL', weight: 3 }
+       ]
+     }
+   }
+ ;
+
+ColumnOptionOptionals
+ : OptionalEnableOrDisable OptionalNovalidate OptionalRelyOrNorely
+   {
+     var keywords = [];
+     if (!$3) {
+       keywords.push({ value: 'RELY', weight: 3 });
+       keywords.push({ value: 'NORELY', weight: 3 });
+       if (!$2) {
+         keywords.push({ value: 'NOVALIDATE', weight: 3 });
+         if (!$1) {
+           keywords.push({ value: 'RELY', weight: 3 });
+           keywords.push({ value: 'NORELY', weight: 3 });
+         }
+       }
+     }
+     if (keywords.length) {
+       $$ = { suggestKeywords: keywords };
+     }
+   }
+ ;
+
+DefaultValue
+ : 'LITERAL'
+ | 'CURRENT_USER' '(' ')'
+ | 'CURRENT_DATE' '(' ')'
+ | 'CURRENT_TIMESTAMP' '(' ')'
+ | 'NULL'
+ ;
+
+OptionalEnableOrDisable
+ :
+ | 'ENABLE'
+ | 'DISABLE'
+ ;
+
+OptionalDisable
+ :
+ | 'DISABLE'
+ ;
+
+OptionalNovalidate
+ :
+ | 'NOVALIDATE'
+ ;
+
+ColumnDataType
+ : PrimitiveType
+ | ArrayType
+ | MapType
+ | StructType
+ | UnionType
+ | ArrayType_INVALID
+ | MapType_INVALID
+ | StructType_INVALID
+ | UnionType_INVALID
+ ;
+
+ColumnDataType_EDIT
+ : ArrayType_EDIT
+ | MapType_EDIT
+ | StructType_EDIT
+ | UnionType_EDIT
+ ;
+
+ArrayType
+ : 'ARRAY' '<' ColumnDataType '>'
+ ;
+
+ArrayType_INVALID
+ : 'ARRAY' '<' '>'
+ ;
+
+ArrayType_EDIT
+ : 'ARRAY' '<' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
+ ;
+
+MapType
+ : 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
+ ;
+
+MapType_INVALID
+ : 'MAP' '<' '>'
+ ;
+
+MapType_EDIT
+ : 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
+ | 'MAP' '<' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getTypeKeywords());
+   }
+ | 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | 'MAP' '<' ',' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ ;
+
+StructType
+ : 'STRUCT' '<' StructDefinitionList '>'
+ ;
+
+StructType_INVALID
+ : 'STRUCT' '<' '>'
+ ;
+
+StructType_EDIT
+ : 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
+ ;
+
+StructDefinitionList
+ : StructDefinition
+ | StructDefinitionList ',' StructDefinition
+ ;
+
+StructDefinitionList_EDIT
+ : StructDefinition_EDIT
+ | StructDefinition_EDIT Commas
+ | StructDefinition_EDIT Commas StructDefinitionList
+ | StructDefinitionList ',' StructDefinition_EDIT
+ | StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
+ ;
+
+StructDefinition
+ : RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
+ ;
+
+StructDefinition_EDIT
+ : Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
+   {
+     parser.suggestKeywords(['COMMENT']);
+   }
+ | Commas RegularOrBacktickedIdentifier ':' AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
+ | RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
+   {
+     parser.suggestKeywords(['COMMENT']);
+   }
+ | RegularOrBacktickedIdentifier ':' AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
+ ;
+
+UnionType
+ : 'UNIONTYPE' '<' ColumnDataTypeList '>'
+ ;
+
+UnionType_INVALID
+ : 'UNIONTYPE' '<' '>'
+ ;
+
+UnionType_EDIT
+ : 'UNIONTYPE' '<' ColumnDataTypeList_EDIT GreaterThanOrError
+ ;
+
+ColumnDataTypeList
+ : ColumnDataType
+ | ColumnDataTypeList ',' ColumnDataType
+ ;
+
+ColumnDataTypeList_EDIT
+ : ColumnDataTypeListInner_EDIT
+ | ColumnDataTypeListInner_EDIT Commas
+ | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
+ | ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
+ | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
+ ;
+
+ColumnDataTypeListInner_EDIT
+ : Commas AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | Commas ColumnDataType_EDIT
+ | AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | ColumnDataType_EDIT
+ ;
+
+GreaterThanOrError
+ : '>'
+ | error
+ ;
+
+TableConstraints
+ : PrimaryKeySpecification
+ | ConstraintList
+ | PrimaryKeySpecification ',' ConstraintList
+ ;
+
+TableConstraints_EDIT
+ : PrimaryKeySpecification_EDIT
+ | PrimaryKeySpecification ',' 'CURSOR'
+   {
+     parser.suggestKeywords(['CONSTRAINT']);
+   }
+ | ConstraintList_EDIT
+ | PrimaryKeySpecification ',' ConstraintList_EDIT
+ | PrimaryKeySpecification_EDIT ',' ConstraintList
+ ;
+
+ConstraintList
+ : TableConstraint
+ | ConstraintList ',' TableConstraint
+ ;
+
+ConstraintList_EDIT
+ : TableConstraint_EDIT
+ | ConstraintList ',' TableConstraint_EDIT
+ ;
+
+PrimaryKeySpecification
+ : PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely
+ ;
+
+PrimaryKeySpecification_EDIT
+ : PrimaryKey_EDIT
+ | PrimaryKey ParenthesizedColumnList_EDIT
+ | PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
+   {
+     parser.suggestKeywordsForOptionalsLR([$5, $4, $3], [
+        [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
+        { value: 'NOVALIDATE', weight: 2 },
+        { value: 'DISABLE', weight: 1 }]);
+   }
+ ;
+
+OptionalRelyOrNorely
+ :
+ | 'RELY'
+ | 'NORELY'
+ ;
+
+PrimaryKey
+ : 'PRIMARY' 'KEY'
+ ;
+
+PrimaryKey_EDIT
+ : 'PRIMARY' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEY']);
+   }
+ ;
+
+ClusteredBy
+ : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ ;
+
+ClusteredBy_EDIT
+ : 'CLUSTERED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
+   {
+     if (!$4) {
+       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
+     } else {
+       parser.suggestKeywords(['INTO']);
+     }
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
+   {
+     parser.suggestKeywords(['BUCKETS']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
+ ;
+
+OptionalSortedBy
+ :
+ | 'SORTED' 'BY' ParenthesizedSortList
+ ;
+
+OptionalSortedBy_EDIT
+ : 'SORTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'SORTED' 'BY' ParenthesizedSortList_EDIT
+ ;
+
+ParenthesizedSortList
+ : '(' SortList ')'
+ ;
+
+ParenthesizedSortList_EDIT
+ : '(' SortList_EDIT RightParenthesisOrError
+ ;
+
+SortList
+ : SortIdentifier
+ | SortList ',' SortIdentifier
+ ;
+
+SortList_EDIT
+ : SortIdentifier_EDIT
+ | SortIdentifier_EDIT ',' SortList
+ | SortList ',' SortIdentifier_EDIT
+ | SortList ',' SortIdentifier_EDIT ',' SortList
+ ;
+
+SortIdentifier
+ : ColumnIdentifier OptionalAscOrDesc
+ ;
+
+SortIdentifier_EDIT
+ : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
+   {
+     parser.checkForKeywords($2);
+   }
+ | ColumnIdentifier_EDIT OptionalAscOrDesc
+ | AnyCursor OptionalAscOrDesc
+   {
+     parser.suggestColumns();
+   }
+ ;
+
+ParenthesizedSkewedValueList
+ : '(' SkewedValueList ')'
+ ;
+
+SkewedValueList
+ : ParenthesizedSimpleValueList
+ | SkewedValueList ',' ParenthesizedSimpleValueList
+ ;
+
+OptionalRowFormat
+ :
+ | RowFormat
+ ;
+
+RowFormat
+ : 'ROW' 'FORMAT' RowFormatSpec
+   {
+     $$ = $3
+   }
+ ;
+
+RowFormat_EDIT
+ : 'ROW' 'CURSOR'
+   {
+     parser.suggestKeywords(['FORMAT']);
+   }
+ | 'ROW' 'FORMAT' 'CURSOR'
+   {
+     parser.suggestKeywords(['DELIMITED', 'SERDE']);
+   }
+ | 'ROW' 'FORMAT' RowFormatSpec_EDIT
+ ;
+
+OptionalStoredAsOrBy
+ :
+ | StoredAsOrBy
+ ;
+
+StoredAsOrBy
+ : StoredAs
+ | 'STORED' 'BY' QuotedValue
+  {
+    $$ = { storedBy: true }
+  }
+ ;
+
+StoredAsOrBy_EDIT
+ : 'STORED' 'CURSOR'
+   {
+     parser.suggestKeywords(['AS', 'BY']);
+   }
+ | StoredAs_EDIT
+ ;
+
+OptionalStoredAs
+ :           -> { suggestKeywords: ['STORED AS'] }
+ | StoredAs
+ ;
+
+StoredAs
+ : 'STORED' 'AS' FileFormat
+ ;
+
+StoredAs_EDIT
+ : 'STORED' 'AS' 'CURSOR'
+   {
+     parser.suggestFileFormats();
+   }
+ ;
+
+FileFormat
+ : 'AVRO'
+ | 'INPUTFORMAT' QuotedValue 'OUTPUTFORMAT' QuotedValue
+ | 'JSONFILE'
+ | 'ORC'
+ | 'PARQUET'
+ | 'RCFILE'
+ | 'SEQUENCEFILE'
+ | 'TEXTFILE'
+ ;
+
+RowFormatSpec
+ : DelimitedRowFormat
+ | 'SERDE' QuotedValue
+ ;
+
+RowFormatSpec_EDIT
+ : DelimitedRowFormat_EDIT
+ ;
+
+DelimitedRowFormat
+ : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
+   {
+     if (!$2 && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
+     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
+     } else if (!$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$6) {
+       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
+     }
+   }
+ ;
+
+DelimitedRowFormat_EDIT
+ : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
+ ;
+
+OptionalFieldsTerminatedBy
+ :
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
+ ;
+
+OptionalFieldsTerminatedBy_EDIT
+ : 'FIELDS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalCollectionItemsTerminatedBy
+ :
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalCollectionItemsTerminatedBy_EDIT
+ : 'COLLECTION' 'CURSOR'
+   {
+     parser.suggestKeywords(['ITEMS TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalMapKeysTerminatedBy
+ :
+ | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalMapKeysTerminatedBy_EDIT
+ : 'MAP' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEYS TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalLinesTerminatedBy
+ :
+ | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalLinesTerminatedBy_EDIT
+ : 'LINES' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'LINES' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalNullDefinedAs
+ :
+ | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
+ ;
+
+OptionalNullDefinedAs_EDIT
+ : 'NULL' 'CURSOR'
+   {
+     parser.suggestKeywords(['DEFINED AS']);
+   }
+ | 'NULL' 'DEFINED' 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ ;
+
+OptionalWithSerdeproperties
+ :
+ | WithSerdeproperties
+ ;
+
+WithSerdeproperties
+ :'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+WithSerdeproperties_EDIT
+ : 'WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ ;
+
+OptionalTblproperties
+ :
+ | TblProperties
+ ;
+
+TblProperties
+ : 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+AsSelectStatement
+ : 'AS' CommitLocations QuerySpecification
+ ;
+
+AsSelectStatement_EDIT
+ : 'AS' CommitLocations 'CURSOR'
+   {
+     parser.suggestKeywords(['SELECT']);
+   }
+ | 'AS' CommitLocations QuerySpecification_EDIT
+ ;
+
+CommitLocations
+ : /* empty */
+   {
+     parser.commitLocations();
+   }
+ ;

+ 100 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_database.jison

@@ -0,0 +1,100 @@
+// 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
+ : CreateDatabase
+ ;
+
+DataDefinition_EDIT
+ : CreateDatabase_EDIT
+ ;
+
+CreateDatabase
+ : 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
+   {
+     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
+   }
+ ;
+
+CreateDatabase_EDIT
+ : 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
+   {
+     if (!$3) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+   }
+ | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
+ | 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
+   {
+     if (!$3) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+     parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
+   }
+ | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
+   {
+     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
+   }
+ | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
+   {
+     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
+   }
+ ;
+
+DatabaseDefinitionOptionals
+ : OptionalComment OptionalHdfsLocation OptionalDbProperties
+   {
+     var keywords = [];
+     if (!$3) {
+       keywords.push('WITH DBPROPERTIES');
+     }
+     if (!$2 && !$3) {
+       keywords.push('LOCATION');
+     }
+     if (!$1 && !$2 && !$3) {
+       keywords.push('COMMENT');
+     }
+     if (keywords.length > 0) {
+       parser.suggestKeywords(keywords);
+     }
+   }
+ ;
+
+DatabaseDefinitionOptionals_EDIT
+ : Comment_INVALID OptionalHdfsLocation OptionalDbProperties
+ | OptionalComment HdfsLocation_EDIT OptionalDbProperties
+ ;
+
+Comment_INVALID
+ : 'COMMENT' SINGLE_QUOTE
+ | 'COMMENT' DOUBLE_QUOTE
+ | 'COMMENT' SINGLE_QUOTE VALUE
+ | 'COMMENT' DOUBLE_QUOTE VALUE
+ ;
+
+OptionalDbProperties
+ :
+ | DbProperties
+ ;
+
+DbProperties
+ : 'WITH' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList
+ | 'WITH' 'DBPROPERTIES'
+ | 'WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['DBPROPERTIES']);
+   }
+ ;

+ 70 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_function.jison

@@ -0,0 +1,70 @@
+// 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
+ : CreateFunction
+ ;
+
+DataDefinition_EDIT
+ : CreateFunction_EDIT
+ ;
+
+CreateFunction
+ : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing
+ ;
+
+CreateFunction_EDIT
+ : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing_EDIT
+ | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing 'CURSOR'
+   {
+     if (!$6) {
+       parser.suggestKeywords(['USING']);
+     } else {
+       parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
+     }
+   }
+ ;
+
+OptionalUsing
+ :
+ | 'USING' OneOrMoreFunctionResources
+ ;
+
+OptionalUsing_EDIT
+ : 'USING' 'CURSOR'
+   {
+     parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
+   }
+ ;
+
+OneOrMoreFunctionResources
+ : FunctionResource
+ | OneOrMoreFunctionResources ',' FunctionResource
+ ;
+
+FunctionResource
+ : FunctionResourceType SingleQuotedValue
+ ;
+
+FunctionResourceType
+ : 'ARCHIVE'
+ | 'FILE'
+ | 'JAR'
+ ;

+ 193 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_index.jison

@@ -0,0 +1,193 @@
+// 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
+ : CreateIndex
+ ;
+
+DataDefinition_EDIT
+ : CreateIndex_EDIT
+ ;
+
+CreateIndex
+ : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat
+   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment
+ ;
+
+CreateIndex_EDIT
+ : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['ON TABLE']);
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
+   {
+     parser.suggestKeywords(['TABLE']);
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' 'CURSOR'
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' 'CURSOR'
+   {
+     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType WithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties InTable_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
+   OptionalTblproperties OptionalComment
+   {
+     if ($13 && parser.yy.result.suggestKeywords && parser.yy.result.suggestKeywords.length === 2) {
+       parser.suggestKeywords(['AS']);
+     }
+   }
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
+   OptionalTblproperties OptionalComment
+ | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
+   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties OptionalComment 'CURSOR'
+   {
+     if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'WITH DEFERRED REBUILD', weight: 7 }, { value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$13 && !$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if ($13 && $13.suggestKeywords && !$14 && !$15 && !$16) {
+       parser.suggestKeywords(parser.createWeightedKeywords($13.suggestKeywords, 5).concat([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]));
+     } else if (!$14 && !$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$15 && !$16 && !$17) {
+       parser.suggestKeywords([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$16 && !$17) {
+       parser.suggestKeywords([{ value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
+     } else if (!$17) {
+       parser.suggestKeywords([{ value: 'COMMENT', weight: 1 }]);
+     }
+   }
+ ;
+
+ExistingTable
+ : SchemaQualifiedTableIdentifier
+   {
+     parser.addTablePrimary($1);
+   }
+ ;
+
+ExistingTable_EDIT
+ : SchemaQualifiedTableIdentifier_EDIT
+ ;
+
+IndexType
+ : QuotedValue
+ ;
+
+IndexType_EDIT
+ : QuotedValue_EDIT
+   {
+     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
+   }
+ ;
+
+OptionalWithDeferredRebuild
+ :
+ | 'WITH' 'DEFERRED' 'REBUILD'
+ ;
+
+WithDeferredRebuild_EDIT
+ : 'WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['DEFERRED REBUILD']);
+   }
+ | 'WITH' 'DEFERRED' 'CURSOR'
+   {
+     parser.suggestKeywords(['REBUILD']);
+   }
+ ;
+
+OptionalIdxProperties
+ :
+ | 'IDXPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+OptionalInTable
+ :
+ | 'IN' 'TABLE' SchemaQualifiedTableIdentifier
+ ;
+
+InTable_EDIT
+ : 'IN' 'CURSOR'
+   {
+     parser.suggestKeywords(['TABLE']);
+   }
+ | 'IN' 'TABLE' 'CURSOR'
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'IN' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
+ ;
+
+ParenthesizedIndexColumnList
+ : '(' IndexColumnList ')'
+ ;
+
+ParenthesizedIndexColumnList_EDIT
+ : '(' IndexColumnList_EDIT RightParenthesisOrError
+   {
+     parser.suggestColumns();
+   }
+ ;
+
+IndexColumnList
+ : ColumnReference
+ | IndexColumnList ',' ColumnReference
+ ;
+
+IndexColumnList_EDIT
+ : AnyCursor
+ | IndexColumnList ',' AnyCursor
+ | AnyCursor ',' IndexColumnList
+ | IndexColumnList ',' AnyCursor ',' IndexColumnList
+ ;

+ 161 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_materialized_view.jison

@@ -0,0 +1,161 @@
+// 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
+ : CreateMaterializedView
+ ;
+
+DataDefinition_EDIT
+ : CreateMaterializedView_EDIT
+ ;
+
+CreateMaterializedView
+ : 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier
+    OptionalDisableRewrite OptionalComment OptionalPartitionedOn OptionalClusteredOrDistributedOn
+    OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties
+    AsSelectStatement
+ ;
+
+CreateMaterializedView_EDIT
+ : 'CREATE' 'MATERIALIZED' 'CURSOR'
+   {
+     parser.suggestKeywords(['VIEW']);
+   }
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists 'CURSOR'
+   {
+     if (!$4) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties 'CURSOR'
+   {
+     parser.suggestKeywordsForOptionalsLR([undefined, $12, $11, $10, $9, $8, $7, $6, $5], [
+       { value: 'AS SELECT', weight: 1 },
+       { value: 'TBLPROPERTIES', weight: 2 },
+       { value: 'LOCATION', weight: 3 },
+       [{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }],
+       [{ value: 'CLUSTERED ON', weight: 5 }, { value: 'DISTRIBUTED ON', weight: 5 }],
+       { value: 'PARTITIONED ON', weight: 6 },
+       { value: 'COMMENT', weight: 7 },
+       { value: 'DISABLE REWRITE', weight: 8 }
+     ]);
+   }
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier DisableRewrite_EDIT OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   PartitionedOn_EDIT OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn ClusteredOrDistributedOn_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
+   OptionalTblproperties
+ | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
+   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
+   OptionalTblproperties AsSelectStatement_EDIT
+ ;
+
+OptionalPartitionedOn
+ :
+ | PartitionedOn
+ ;
+
+PartitionedOn
+ : 'PARTITIONED' 'ON' ParenthesizedColumnList
+ ;
+
+PartitionedOn_EDIT
+ : 'PARTITIONED' 'CURSOR'
+   {
+     parser.suggestKeywords(['ON']);
+   }
+ | 'PARTITIONED' 'ON' ParenthesizedColumnList_EDIT
+ ;
+
+OptionalClusteredOrDistributedOn
+ :
+ | ClusteredOn
+ | DistributedOn SortedOn
+ ;
+
+ClusteredOrDistributedOn_EDIT
+ : ClusteredOn_EDIT
+ | DistributedOn_EDIT
+ | DistributedOn 'CURSOR'
+   {
+     parser.suggestKeywords(['SORTED ON']);
+   }
+ | DistributedOn SortedOn_EDIT
+ ;
+
+ClusteredOn
+ : 'CLUSTERED' 'ON' ParenthesizedColumnList
+ ;
+
+ClusteredOn_EDIT
+ : 'CLUSTERED' 'CURSOR'
+   {
+     parser.suggestKeywords(['ON']);
+   }
+ | 'CLUSTERED' 'ON' ParenthesizedColumnList_EDIT
+ ;
+
+DistributedOn
+ : 'DISTRIBUTED' 'ON' ParenthesizedColumnList
+ ;
+
+DistributedOn_EDIT
+ : 'DISTRIBUTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['ON']);
+   }
+ | 'DISTRIBUTED' 'ON' ParenthesizedColumnList_EDIT
+ ;
+
+SortedOn
+ : 'SORTED' 'ON' ParenthesizedColumnList
+ ;
+
+SortedOn_EDIT
+ : 'SORTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['ON']);
+   }
+ | 'SORTED' 'ON' ParenthesizedColumnList_EDIT
+ ;
+
+OptionalDisableRewrite
+ :
+ | 'DISABLE' 'REWRITE'
+ ;
+
+DisableRewrite_EDIT
+ : 'DISABLE' 'CURSOR'
+   {
+     parser.suggestKeywords(['REWRITE']);
+   }
+ ;

+ 23 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_role.jison

@@ -0,0 +1,23 @@
+// 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
+ : CreateRole
+ ;
+
+CreateRole
+ : 'CREATE' 'ROLE' RegularIdentifier
+ ;

+ 208 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_table.jison

@@ -0,0 +1,208 @@
+// 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
+ : CreateTable
+ ;
+
+DataDefinition_EDIT
+ : CreateTable_EDIT
+ ;
+
+CreateTable
+ : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart
+ ;
+
+CreateTable_EDIT
+ : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
+ | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists 'CURSOR'
+   {
+     if (!$6) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+   }
+ | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists_EDIT
+ ;
+
+TableDefinitionRightPart
+ : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ ;
+
+TableDefinitionRightPart_EDIT
+ : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   ClusteredBy_EDIT OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy SkewedBy_EDIT OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy RowFormat_EDIT OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat StoredAsOrBy_EDIT
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   WithSerdeproperties_EDIT OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties HdfsLocation_EDIT OptionalTblproperties OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties AsSelectStatement_EDIT
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
+   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
+   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties 'CURSOR'
+   {
+     var keywords = [];
+     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'LIKE', weight: 1 });
+     } else {
+       if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'COMMENT', weight: 10 });
+       }
+       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'PARTITIONED BY', weight: 9 });
+       }
+       if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'CLUSTERED BY', weight: 8 });
+       }
+       if (!$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'SKEWED BY', weight: 7 });
+       } else if ($5 && $5.suggestKeywords && !$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 7)); // Get the last optional from SKEWED BY
+       }
+       if (!$6 && !$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'ROW FORMAT', weight: 6 });
+       } else if ($6 && $6.suggestKeywords && !$7 && !$8 && !$9 && !$10) {
+         keywords = keywords.concat(parser.createWeightedKeywords($6.suggestKeywords, 6));
+       }
+       if (!$7 && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'STORED AS', weight: 5 });
+         keywords.push({ value: 'STORED BY', weight: 5 });
+       } else if ($7 && $7.storedBy && !$8 && !$9 && !$10) {
+         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 4 });
+       }
+       if (!$9 && !$10) {
+         keywords.push({ value: 'LOCATION', weight: 3 });
+       }
+       if (!$10) {
+         keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
+       }
+       keywords.push({ value: 'AS', weight: 1 });
+     }
+
+     parser.suggestKeywords(keywords);
+   }
+ ;
+
+TableIdentifierAndOptionalColumnSpecification
+ : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
+   {
+     parser.addNewTableLocation(@1, $1, $2);
+     $$ = $2;
+   }
+ ;
+
+TableIdentifierAndOptionalColumnSpecification_EDIT
+ : SchemaQualifiedIdentifier ColumnSpecificationsOrLike_EDIT
+ | SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
+ ;
+
+OptionalColumnSpecificationsOrLike
+ :
+ | ParenthesizedColumnSpecificationList
+ | 'LIKE' SchemaQualifiedTableIdentifier    -> []
+ ;
+
+ColumnSpecificationsOrLike_EDIT
+ : ParenthesizedColumnSpecificationList_EDIT
+ | 'LIKE' 'CURSOR'
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'LIKE' SchemaQualifiedTableIdentifier_EDIT
+ ;
+
+OptionalPartitionedBy
+ :
+ | PartitionedBy
+ ;
+
+PartitionedBy
+ : 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList
+ ;
+
+PartitionedBy_EDIT
+ : 'PARTITIONED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'PARTITIONED' 'CURSOR' ParenthesizedColumnSpecificationList
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList_EDIT
+ | 'PARTITIONED' ParenthesizedColumnSpecificationList_EDIT
+ | 'PARTITION' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'PARTITION' 'BY' 'CURSOR'
+   {
+     parser.suggestKeywords(['HASH', 'RANGE']);
+   }
+ ;
+
+OptionalClusteredBy
+ :
+ | ClusteredBy
+ ;
+
+OptionalSkewedBy
+ :
+ | SkewedBy
+ ;
+
+SkewedBy
+ : 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList  -> { suggestKeywords: ['STORED AS DIRECTORIES'] }
+ | 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList 'STORED_AS_DIRECTORIES' // Hack otherwise ambiguous with OptionalStoredAsOrBy
+ ;
+
+SkewedBy_EDIT
+ : 'SKEWED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR'
+   {
+     parser.suggestKeywords(['ON']);
+   }
+ ;
+
+OptionalAsSelectStatement
+ :
+ | AsSelectStatement
+ ;

+ 34 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_temporary_function.jison

@@ -0,0 +1,34 @@
+// 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
+ : CreateTemporaryFunction
+ ;
+
+DataDefinition_EDIT
+ : CreateTemporaryFunction_EDIT
+ ;
+
+CreateTemporaryFunction
+ : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'AS' SingleQuotedValue
+ ;
+
+CreateTemporaryFunction_EDIT
+ : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ ;

+ 70 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_temporary_macro.jison

@@ -0,0 +1,70 @@
+// 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
+ : CreateTemporaryMacro
+ ;
+
+DataDefinition_EDIT
+ : CreateTemporaryMacro_EDIT
+ ;
+
+CreateTemporaryMacro
+ : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression
+ ;
+
+CreateTemporaryMacro_EDIT
+ : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT
+ | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT ValueExpression
+ | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments 'CURSOR'
+   {
+     parser.suggestFunctions();
+   }
+ | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression_EDIT
+ ;
+
+MacroArguments
+ : '(' ')'
+ | '(' MacroArgumentList ')'
+ ;
+
+MacroArguments_EDIT
+ : '(' MacroArgumentList_EDIT RightParenthesisOrError
+ ;
+
+MacroArgumentList
+ : MacroArgument
+ | MacroArgumentList ',' MacroArgument
+ ;
+
+MacroArgumentList_EDIT
+ : MacroArgument_EDIT
+ | MacroArgumentList ',' MacroArgument_EDIT
+ | MacroArgument_EDIT ',' MacroArgumentList
+ | MacroArgumentList ',' MacroArgument_EDIT ',' MacroArgumentList
+ ;
+
+MacroArgument
+ : RegularIdentifier ColumnDataType
+ ;
+
+MacroArgument_EDIT
+ : RegularIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | RegularIdentifier ColumnDataType_EDIT
+ ;

+ 92 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/create/create_view.jison

@@ -0,0 +1,92 @@
+// 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
+ : CreateView
+ ;
+
+DataDefinition_EDIT
+ : CreateView_EDIT
+ ;
+
+CreateView
+ : 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
+ ;
+
+CreateView_EDIT
+ : 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
+   {
+     if (!$3) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
+   {
+     if (!$3) {
+       parser.suggestKeywords(['IF NOT EXISTS']);
+     }
+   }
+ | 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
+ | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment OptionalTblproperties
+ | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'CURSOR'
+   {
+     var keywords = [{value: 'AS', weight: 1 }];
+     if (!$7) {
+       keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
+       if (!$6) {
+         keywords.push({ value: 'COMMENT', weight: 3 });
+       }
+     }
+     parser.suggestKeywords(keywords);
+   }
+ | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' 'CURSOR'
+   {
+     parser.suggestKeywords(['SELECT']);
+   }
+ | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification_EDIT
+ | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
+ ;
+
+OptionalParenthesizedViewColumnList
+ :
+ | ParenthesizedViewColumnList
+ ;
+
+ParenthesizedViewColumnList
+ : '(' ViewColumnList ')'
+ ;
+
+ParenthesizedViewColumnList_EDIT
+ : '(' ViewColumnList_EDIT RightParenthesisOrError
+   {
+     if (!$2) {
+       parser.suggestKeywords(['COMMENT']);
+     }
+   }
+ ;
+
+ViewColumnList
+ : ColumnReference OptionalComment
+ | ViewColumnList ',' ColumnReference OptionalComment
+ ;
+
+ViewColumnList_EDIT
+ : ColumnReference OptionalComment 'CURSOR'                                        -> $2
+ | ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList                     -> $2
+ | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR'                     -> $4
+ | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList  -> $4
+ ;

+ 119 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/explain/explain.jison

@@ -0,0 +1,119 @@
+// 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.
+
+SqlStatement
+ : ExplainClause DataDefinition
+ | ExplainClause DataManipulation
+ | ExplainClause QuerySpecification
+ ;
+
+SqlStatement_EDIT
+ : ExplainClause_EDIT
+ | ExplainClause DataDefinition_EDIT
+ | ExplainClause DataManipulation_EDIT
+ | ExplainClause QuerySpecification_EDIT
+ | ExplainClause_EDIT DataDefinition
+ | ExplainClause_EDIT DataManipulation
+ | ExplainClause_EDIT QuerySpecification
+ ;
+
+ExplainClause
+ : 'EXPLAIN' OptionalExplainTypes
+ ;
+
+ExplainClause_EDIT
+ : 'EXPLAIN' OptionalExplainTypes 'CURSOR'
+   {
+     if (!$2) {
+       parser.suggestDdlAndDmlKeywords([
+         { value: 'AST', weight: 2 },
+         { value: 'AUTHORIZATION', weight: 2 },
+         { value: 'CBO', weight: 2 },
+         { value: 'DEPENDENCY', weight: 2 },
+         { value: 'EXTENDED', weight: 2 },
+         { value: 'FORMATTED CBO', weight: 2 },
+         { value: 'LOCKS', weight: 2 },
+         { value: 'VECTORIZATION', weight: 2 }
+       ]);
+     } else if ($2 && $2.suggestKeywords) {
+       parser.suggestDdlAndDmlKeywords($2.suggestKeywords);
+     } else {
+       parser.suggestDdlAndDmlKeywords();
+     }
+   }
+ | 'EXPLAIN' 'FORMATTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['CBO']);
+   }
+ ;
+
+OptionalExplainTypes
+ :
+ | 'AST'
+ | 'AUTHORIZATION'
+ | 'FORMATTED' 'CBO' OptionalCostOrJoincost
+   {
+     if (!$3) {
+       $$ = { suggestKeywords: ['COST', 'JOINCOST'] };
+     }
+   }
+ | 'CBO' OptionalCostOrJoincost
+   {
+     if (!$2) {
+       $$ = { suggestKeywords: ['COST', 'JOINCOST'] };
+     }
+   }
+ | 'DEPENDENCY'
+ | 'EXTENDED'
+ | 'LOCKS'
+ | 'VECTORIZATION' OptionalOnly OptionalVectorizationTypes
+   {
+     var keywords = [];
+     if (!$3) {
+       keywords = keywords.concat([
+         { weight: 1, value: 'DETAIL' },
+         { weight: 1, value: 'EXPRESSION' },
+         { weight: 1, value: 'OPERATOR' },
+         { weight: 1, value: 'SUMMARY' }
+       ]);
+     }
+     if (!$2) {
+       keywords.push({ weight: 2, value: 'ONLY' });
+     }
+     if (keywords.length) {
+       $$ = { suggestKeywords: keywords };
+     }
+   }
+ ;
+
+OptionalCostOrJoincost
+ :
+ | 'COST'
+ | 'JOINCOST'
+ ;
+
+OptionalOnly
+ :
+ | 'ONLY'
+ ;
+
+OptionalVectorizationTypes
+ :
+ | 'DETAIL'
+ | 'EXPRESSION'
+ | 'OPERATOR'
+ | 'SUMMARY'
+ ;

+ 0 - 236
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_analyze.jison

@@ -1,236 +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
- : AnalyzeStatement
- ;
-
-DataDefinition_EDIT
- : AnalyzeStatement_EDIT
- ;
-
-SqlStatement
- : ExplainClause DataDefinition
- | ExplainClause DataManipulation
- | ExplainClause QuerySpecification
- ;
-
-SqlStatement_EDIT
- : ExplainClause_EDIT
- | ExplainClause DataDefinition_EDIT
- | ExplainClause DataManipulation_EDIT
- | ExplainClause QuerySpecification_EDIT
- | ExplainClause_EDIT DataDefinition
- | ExplainClause_EDIT DataManipulation
- | ExplainClause_EDIT QuerySpecification
- ;
-
-AnalyzeStatement
- : 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
-   {
-     parser.addTablePrimary($3);
-   }
- ;
-
-AnalyzeStatement_EDIT
- : 'ANALYZE' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'ANALYZE' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables({ onlyTables: true });
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec
-   {
-     if (parser.yy.result.suggestTables) {
-       parser.yy.result.suggestTables.onlyTables = true;
-     }
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT
-   {
-     parser.addTablePrimary($3);
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     if (!$4) {
-       parser.suggestKeywords([{ value: 'PARTITION', weight: 2 }, { value: 'COMPUTE STATISTICS', weight: 1 }]);
-     } else {
-       parser.suggestKeywords(['COMPUTE STATISTICS']);
-     }
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'CURSOR'
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(['STATISTICS']);
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' 'CURSOR' OptionalForColumns OptionalCacheMetadata OptionalNoscan
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$8, $9, $10], [{ value: 'FOR COLUMNS', weight: 3 }, { value: 'CACHE METADATA', weight: 2 }, { value: 'NOSCAN', weight: 1 }]));
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' ForColumns 'CURSOR' OptionalCacheMetadata OptionalNoscan
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$9, $10], [{ value: 'CACHE METADATA', weight: 2 }, { value: 'NOSCAN', weight: 1 }]));
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns CacheMetadata 'CURSOR' OptionalNoscan
-   {
-     parser.addTablePrimary($3);
-     parser.suggestKeywords(parser.getKeywordsForOptionalsLR([$10], [{ value: 'NOSCAN', weight: 1 }]));
-   }
- | 'ANALYZE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec
-   {
-     parser.suggestKeywords(['TABLE']);
-     parser.addTablePrimary($3);
-   }
- | 'ANALYZE' 'CURSOR' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
-   {
-     parser.suggestKeywords(['TABLE']);
-     parser.addTablePrimary($3);
-   }
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier_EDIT OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec_EDIT 'COMPUTE' 'STATISTICS' OptionalForColumns OptionalCacheMetadata OptionalNoscan
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' ForColumns_EDIT OptionalCacheMetadata OptionalNoscan
- | 'ANALYZE' 'TABLE' SchemaQualifiedTableIdentifier OptionalPartitionSpec 'COMPUTE' 'STATISTICS' OptionalForColumns CacheMetadata_EDIT OptionalNoscan
- ;
-
-OptionalForColumns
- :
- | ForColumns
- ;
-
-ForColumns
- : 'FOR' 'COLUMNS'
- ;
-
-ForColumns_EDIT
- : 'FOR' 'CURSOR'
-   {
-     parser.suggestKeywords(['COLUMNS']);
-   }
- ;
-
-OptionalCacheMetadata
- :
- | CacheMetadata
- ;
-
-CacheMetadata
- : 'CACHE' 'METADATA'
- ;
-
-CacheMetadata_EDIT
- : 'CACHE' 'CURSOR'
-   {
-     parser.suggestKeywords(['METADATA']);
-   }
- ;
-
-OptionalNoscan
- :
- | 'NOSCAN'
- ;
-
-ExplainClause
- : 'EXPLAIN' OptionalExplainTypes
- ;
-
-ExplainClause_EDIT
- : 'EXPLAIN' OptionalExplainTypes 'CURSOR'
-   {
-     if (!$2) {
-       parser.suggestDdlAndDmlKeywords([
-         { value: 'AST', weight: 2 },
-         { value: 'AUTHORIZATION', weight: 2 },
-         { value: 'CBO', weight: 2 },
-         { value: 'DEPENDENCY', weight: 2 },
-         { value: 'EXTENDED', weight: 2 },
-         { value: 'FORMATTED CBO', weight: 2 },
-         { value: 'LOCKS', weight: 2 },
-         { value: 'VECTORIZATION', weight: 2 }
-       ]);
-     } else if ($2 && $2.suggestKeywords) {
-       parser.suggestDdlAndDmlKeywords($2.suggestKeywords);
-     } else {
-       parser.suggestDdlAndDmlKeywords();
-     }
-   }
- | 'EXPLAIN' 'FORMATTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['CBO']);
-   }
- ;
-
-OptionalExplainTypes
- :
- | 'AST'
- | 'AUTHORIZATION'
- | 'FORMATTED' 'CBO' OptionalCostOrJoincost
-   {
-     if (!$3) {
-       $$ = { suggestKeywords: ['COST', 'JOINCOST'] };
-     }
-   }
- | 'CBO' OptionalCostOrJoincost
-   {
-     if (!$2) {
-       $$ = { suggestKeywords: ['COST', 'JOINCOST'] };
-     }
-   }
- | 'DEPENDENCY'
- | 'EXTENDED'
- | 'LOCKS'
- | 'VECTORIZATION' OptionalOnly OptionalVectorizationTypes
-   {
-     var keywords = [];
-     if (!$3) {
-       keywords = keywords.concat([
-         { weight: 1, value: 'DETAIL' },
-         { weight: 1, value: 'EXPRESSION' },
-         { weight: 1, value: 'OPERATOR' },
-         { weight: 1, value: 'SUMMARY' }
-       ]);
-     }
-     if (!$2) {
-       keywords.push({ weight: 2, value: 'ONLY' });
-     }
-     if (keywords.length) {
-       $$ = { suggestKeywords: keywords };
-     }
-   }
- ;
-
-OptionalCostOrJoincost
- :
- | 'COST'
- | 'JOINCOST'
- ;
-
-OptionalOnly
- :
- | 'ONLY'
- ;
-
-OptionalVectorizationTypes
- :
- | 'DETAIL'
- | 'EXPRESSION'
- | 'OPERATOR'
- | 'SUMMARY'
- ;

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

@@ -1,1596 +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
- : CreateStatement
- ;
-
-DataDefinition_EDIT
- : CreateStatement_EDIT
- ;
-
-CreateStatement
- : DatabaseDefinition
- | TableDefinition
- | ViewDefinition
- | MaterializedViewDefinition
- | RoleDefinition
- | FunctionDefinition
- | IndexDefinition
- | MacroDefinition
- ;
-
-CreateStatement_EDIT
- : DatabaseDefinition_EDIT
- | TableDefinition_EDIT
- | ViewDefinition_EDIT
- | MaterializedViewDefinition_EDIT
- | FunctionDefinition_EDIT
- | IndexDefinition_EDIT
- | MacroDefinition_EDIT
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'CURSOR'
-   {
-     if ($4) {
-       parser.suggestKeywords(['TABLE']);
-     } else {
-       if ($2 && !$3) {
-         parser.suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']);
-       } else if (!$2 && !$3) {
-         parser.suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'MATERIALIZED VIEW', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'TRANSACTIONAL TABLE', 'VIEW']);
-       } else if ($3) {
-         parser.suggestKeywords(['TABLE']);
-       }
-     }
-   }
- ;
-
-DatabaseDefinition
- : 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- ;
-
-DatabaseDefinition_EDIT
- : 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-     parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- ;
-
-DatabaseDefinitionOptionals
- : OptionalComment OptionalHdfsLocation OptionalDbProperties
-   {
-     var keywords = [];
-     if (!$3) {
-       keywords.push('WITH DBPROPERTIES');
-     }
-     if (!$2 && !$3) {
-       keywords.push('LOCATION');
-     }
-     if (!$1 && !$2 && !$3) {
-       keywords.push('COMMENT');
-     }
-     if (keywords.length > 0) {
-       parser.suggestKeywords(keywords);
-     }
-   }
- ;
-
-DatabaseDefinitionOptionals_EDIT
- : OptionalComment_INVALID OptionalHdfsLocation OptionalDbProperties
- | OptionalComment HdfsLocation_EDIT OptionalDbProperties
- ;
-
-OptionalComment
- :
- | Comment
- ;
-
-Comment
- : 'COMMENT' QuotedValue
- ;
-
-OptionalComment_INVALID
- : Comment_INVALID
- ;
-
-Comment_INVALID
- : 'COMMENT' SINGLE_QUOTE
- | 'COMMENT' DOUBLE_QUOTE
- | 'COMMENT' SINGLE_QUOTE VALUE
- | 'COMMENT' DOUBLE_QUOTE VALUE
- ;
-
-
-OptionalDbProperties
- :
- | DbProperties
- ;
-
-DbProperties
- : 'WITH' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList
- | 'WITH' 'DBPROPERTIES'
- | 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['DBPROPERTIES']);
-   }
- ;
-
-ParenthesizedPropertyAssignmentList
- : '(' PropertyAssignmentList ')'
- ;
-
-PropertyAssignmentList
- : PropertyAssignment
- | PropertyAssignmentList ',' PropertyAssignment
- ;
-
-PropertyAssignment
- : QuotedValue '=' UnsignedValueSpecification
- ;
-
-TableDefinition
- : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart
- ;
-
-TableDefinition_EDIT
- : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists_EDIT
- ;
-
-TableDefinitionRightPart
- : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- ;
-
-TableDefinitionRightPart_EDIT
- : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   ClusteredBy_EDIT OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy SkewedBy_EDIT OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy RowFormat_EDIT OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat StoredAsOrBy_EDIT
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   WithSerdeproperties_EDIT OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties HdfsLocation_EDIT OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties AsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties 'CURSOR'
-   {
-     var keywords = [];
-     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-       keywords.push({ value: 'LIKE', weight: 1 });
-     } else {
-       if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'COMMENT', weight: 10 });
-       }
-       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'PARTITIONED BY', weight: 9 });
-       }
-       if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'CLUSTERED BY', weight: 8 });
-       }
-       if (!$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'SKEWED BY', weight: 7 });
-       } else if ($5 && $5.suggestKeywords && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 7)); // Get the last optional from SKEWED BY
-       }
-       if (!$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'ROW FORMAT', weight: 6 });
-       } else if ($6 && $6.suggestKeywords && !$7 && !$8 && !$9 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($6.suggestKeywords, 6));
-       }
-       if (!$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'STORED AS', weight: 5 });
-         keywords.push({ value: 'STORED BY', weight: 5 });
-       } else if ($7 && $7.storedBy && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 4 });
-       }
-       if (!$9 && !$10) {
-         keywords.push({ value: 'LOCATION', weight: 3 });
-       }
-       if (!$10) {
-         keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
-       }
-       keywords.push({ value: 'AS', weight: 1 });
-     }
-
-     parser.suggestKeywords(keywords);
-   }
- ;
-
-TableIdentifierAndOptionalColumnSpecification
- : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
-   {
-     parser.addNewTableLocation(@1, $1, $2);
-     $$ = $2;
-   }
- ;
-
-TableIdentifierAndOptionalColumnSpecification_EDIT
- : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
- | SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
- ;
-
-OptionalColumnSpecificationsOrLike
- :
- | ParenthesizedColumnSpecificationList
- | 'LIKE' SchemaQualifiedTableIdentifier    -> []
- ;
-
-OptionalColumnSpecificationsOrLike_EDIT
- : ParenthesizedColumnSpecificationList_EDIT
- | 'LIKE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'LIKE' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-ParenthesizedColumnSpecificationList
- : '(' ColumnSpecificationList ')'                              -> $2
- | '(' ColumnSpecificationList ',' TableConstraints ')'  -> $2
- ;
-
-ParenthesizedColumnSpecificationList_EDIT
- : '(' ColumnSpecificationList_EDIT RightParenthesisOrError
- | '(' ColumnSpecificationList ',' TableConstraints_EDIT RightParenthesisOrError
- | '(' ColumnSpecificationList ',' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords([{ value: 'PRIMARY KEY', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }]);
-   }
- ;
-
-ColumnSpecificationList
- : ColumnSpecification                              -> [$1]
- | ColumnSpecificationList ',' ColumnSpecification  -> $1.concat($3)
- ;
-
-ColumnSpecificationList_EDIT
- : ColumnSpecification_EDIT
- | ColumnSpecification_EDIT ',' ColumnSpecificationList
- | ColumnSpecificationList ',' ColumnSpecification_EDIT
- | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
- | ColumnSpecification 'CURSOR'
-   {
-     parser.checkForKeywords($1);
-   }
- | ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
-   {
-     parser.checkForKeywords($1);
-   }
- | ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
-   {
-     parser.checkForKeywords($3);
-   }
- | ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
-   {
-     parser.checkForKeywords($3);
-   }
- ;
-
-ColumnSpecification
- : ColumnIdentifier ColumnDataType OptionalColumnOptions OptionalComment
-   {
-     $$ = $1;
-     $$.type = $2;
-     var keywords = [];
-     if (!$4) {
-       keywords = keywords.concat([
-         { value: 'COMMENT', weight: 1 },
-         { value: 'CHECK', weight: 2 },
-         { value: 'PRIMARY KEY', weight: 2 },
-         { value: 'UNIQUE', weight: 2 },
-         { value: 'NOT NULL', weight: 2 },
-         { value: 'DEFAULT', weight: 2 }
-       ]);
-       if (!$3 && $2.toLowerCase() === 'double') {
-         keywords.push({ value: 'PRECISION', weight: 3 });
-       } else if ($3 && $3.suggestKeywords) {
-         keywords = keywords.concat($3.suggestKeywords)
-       }
-     }
-     if (keywords.length > 0) {
-       $$.suggestKeywords = keywords;
-     }
-   }
- ;
-
-ColumnSpecification_EDIT
- : ColumnIdentifier 'CURSOR' OptionalColumnOptions OptionalComment
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions OptionalComment
- ;
-
-OptionalColumnOptions
- :
- | ColumnOptions
- ;
-
-ColumnOptions
- : ColumnOption
- | ColumnOptions ColumnOption
- ;
-
-ColumnOption
- : 'PRIMARY' 'KEY' ColumnOptionOptionals                  -> $3
- | 'PRIMARY'                                              -> { suggestKeywords: [{ value: 'KEY', weight: 3 }] }
- | 'UNIQUE' ColumnOptionOptionals                         -> $2
- | 'NOT' 'NULL' ColumnOptionOptionals                     -> $3
- | 'NOT'                                                  -> { suggestKeywords: [{ value: 'NULL', weight: 3 }] }
- | 'DEFAULT' DefaultValue ColumnOptionOptionals           -> $3
- | 'CHECK' '(' ValueExpression ')' ColumnOptionOptionals  -> $5
- | 'DEFAULT'
-   {
-     $$ = {
-       suggestKeywords: [
-         { value: 'LITERAL', weight: 3 },
-         { value: 'CURRENT_USER()', weight: 3 },
-         { value: 'CURRENT_DATE()', weight: 3 },
-         { value: 'CURRENT_TIMESTAMP()', weight: 3 },
-         { value: 'NULL', weight: 3 }
-       ]
-     }
-   }
- ;
-
-ColumnOptionOptionals
- : OptionalEnableOrDisable OptionalNovalidate OptionalRelyOrNorely
-   {
-     var keywords = [];
-     if (!$3) {
-       keywords.push({ value: 'RELY', weight: 3 });
-       keywords.push({ value: 'NORELY', weight: 3 });
-       if (!$2) {
-         keywords.push({ value: 'NOVALIDATE', weight: 3 });
-         if (!$1) {
-           keywords.push({ value: 'RELY', weight: 3 });
-           keywords.push({ value: 'NORELY', weight: 3 });
-         }
-       }
-     }
-     if (keywords.length) {
-       $$ = { suggestKeywords: keywords };
-     }
-   }
- ;
-
-DefaultValue
- : 'LITERAL'
- | 'CURRENT_USER' '(' ')'
- | 'CURRENT_DATE' '(' ')'
- | 'CURRENT_TIMESTAMP' '(' ')'
- | 'NULL'
- ;
-
-OptionalEnableOrDisable
- :
- | 'ENABLE'
- | 'DISABLE'
- ;
-
-OptionalDisable
- :
- | 'DISABLE'
- ;
-
-OptionalNovalidate
- :
- | 'NOVALIDATE'
- ;
-
-ColumnDataType
- : PrimitiveType
- | ArrayType
- | MapType
- | StructType
- | UnionType
- | ArrayType_INVALID
- | MapType_INVALID
- | StructType_INVALID
- | UnionType_INVALID
- ;
-
-ColumnDataType_EDIT
- : ArrayType_EDIT
- | MapType_EDIT
- | StructType_EDIT
- | UnionType_EDIT
- ;
-
-ArrayType
- : 'ARRAY' '<' ColumnDataType '>'
- ;
-
-ArrayType_INVALID
- : 'ARRAY' '<' '>'
- ;
-
-ArrayType_EDIT
- : 'ARRAY' '<' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
- ;
-
-MapType
- : 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
- ;
-
-MapType_INVALID
- : 'MAP' '<' '>'
- ;
-
-MapType_EDIT
- : 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
- | 'MAP' '<' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-   }
- | 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | 'MAP' '<' ',' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- ;
-
-StructType
- : 'STRUCT' '<' StructDefinitionList '>'
- ;
-
-StructType_INVALID
- : 'STRUCT' '<' '>'
- ;
-
-StructType_EDIT
- : 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
- ;
-
-StructDefinitionList
- : StructDefinition
- | StructDefinitionList ',' StructDefinition
- ;
-
-StructDefinitionList_EDIT
- : StructDefinition_EDIT
- | StructDefinition_EDIT Commas
- | StructDefinition_EDIT Commas StructDefinitionList
- | StructDefinitionList ',' StructDefinition_EDIT
- | StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
- ;
-
-StructDefinition
- : RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
- ;
-
-StructDefinition_EDIT
- : Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
-   {
-     parser.suggestKeywords(['COMMENT']);
-   }
- | Commas RegularOrBacktickedIdentifier ':' AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
- | RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
-   {
-     parser.suggestKeywords(['COMMENT']);
-   }
- | RegularOrBacktickedIdentifier ':' AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
- ;
-
-UnionType
- : 'UNIONTYPE' '<' ColumnDataTypeList '>'
- ;
-
-UnionType_INVALID
- : 'UNIONTYPE' '<' '>'
- ;
-
-UnionType_EDIT
- : 'UNIONTYPE' '<' ColumnDataTypeList_EDIT GreaterThanOrError
- ;
-
-ColumnDataTypeList
- : ColumnDataType
- | ColumnDataTypeList ',' ColumnDataType
- ;
-
-ColumnDataTypeList_EDIT
- : ColumnDataTypeListInner_EDIT
- | ColumnDataTypeListInner_EDIT Commas
- | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
- | ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
- | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
- ;
-
-ColumnDataTypeListInner_EDIT
- : Commas AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | Commas ColumnDataType_EDIT
- | AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | ColumnDataType_EDIT
- ;
-
-GreaterThanOrError
- : '>'
- | error
- ;
-
-TableConstraints
- : PrimaryKeySpecification
- | ConstraintList
- | PrimaryKeySpecification ',' ConstraintList
- ;
-
-TableConstraints_EDIT
- : PrimaryKeySpecification_EDIT
- | PrimaryKeySpecification ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['CONSTRAINT']);
-   }
- | ConstraintList_EDIT
- | PrimaryKeySpecification ',' ConstraintList_EDIT
- | PrimaryKeySpecification_EDIT ',' ConstraintList
- ;
-
-ConstraintList
- : TableConstraint
- | ConstraintList ',' TableConstraint
- ;
-
-ConstraintList_EDIT
- : TableConstraint_EDIT
- | ConstraintList ',' TableConstraint_EDIT
- ;
-
-PrimaryKeySpecification
- : PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely
- ;
-
-PrimaryKeySpecification_EDIT
- : PrimaryKey_EDIT
- | PrimaryKey ParenthesizedColumnList_EDIT
- | PrimaryKey ParenthesizedColumnList OptionalDisable OptionalNovalidate OptionalRelyOrNorely 'CURSOR'
-   {
-     parser.suggestKeywordsForOptionalsLR([$5, $4, $3], [
-        [{ value: 'RELY', weight: 1 }, { value: 'NORELY', weight: 1 }],
-        { value: 'NOVALIDATE', weight: 2 },
-        { value: 'DISABLE', weight: 1 }]);
-   }
- ;
-
-ForeignKeySpecification
- : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList
-   {
-     parser.addTablePrimary($5);
-   }
- ;
-
-ForeignKeySpecification_EDIT
- : 'FOREIGN' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEY']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList_EDIT
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['REFERENCES']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier_EDIT
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList_EDIT
-   {
-     parser.addTablePrimary($5);
-   }
- ;
-
-OptionalRelyOrNorely
- :
- | 'RELY'
- | 'NORELY'
- ;
-
-PrimaryKey
- : 'PRIMARY' 'KEY'
- ;
-
-PrimaryKey_EDIT
- : 'PRIMARY' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEY']);
-   }
- ;
-
-OptionalPartitionedBy
- :
- | PartitionedBy
- ;
-
-PartitionedBy
- : 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList
- ;
-
-PartitionedBy_EDIT
- : 'PARTITIONED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITIONED' 'CURSOR' ParenthesizedColumnSpecificationList
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList_EDIT
- | 'PARTITIONED' ParenthesizedColumnSpecificationList_EDIT
- | 'PARTITION' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITION' 'BY' 'CURSOR'
-   {
-     parser.suggestKeywords(['HASH', 'RANGE']);
-   }
- ;
-
-OptionalPartitionedOn
- :
- | PartitionedOn
- ;
-
-PartitionedOn
- : 'PARTITIONED' 'ON' ParenthesizedColumnList
- ;
-
-PartitionedOn_EDIT
- : 'PARTITIONED' 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'PARTITIONED' 'ON' ParenthesizedColumnList_EDIT
- ;
-
-LessThanOrEqualTo
- : '<'
- | 'COMPARISON_OPERATOR' // This is fine for autocompletion
- ;
-
-OptionalClusteredBy
- :
- | ClusteredBy
- ;
-
-ClusteredBy
- : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- ;
-
-ClusteredBy_EDIT
- : 'CLUSTERED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
-     } else {
-       parser.suggestKeywords(['INTO']);
-     }
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
-   {
-     parser.suggestKeywords(['BUCKETS']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
- ;
-
-OptionalClusteredOrDistributedOn
- :
- | ClusteredOn
- | DistributedOn SortedOn
- ;
-
-ClusteredOrDistributedOn_EDIT
- : ClusteredOn_EDIT
- | DistributedOn_EDIT
- | DistributedOn 'CURSOR'
-   {
-     parser.suggestKeywords(['SORTED ON']);
-   }
- | DistributedOn SortedOn_EDIT
- ;
-
-ClusteredOn
- : 'CLUSTERED' 'ON' ParenthesizedColumnList
- ;
-
-ClusteredOn_EDIT
- : 'CLUSTERED' 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'CLUSTERED' 'ON' ParenthesizedColumnList_EDIT
- ;
-
-DistributedOn
- : 'DISTRIBUTED' 'ON' ParenthesizedColumnList
- ;
-
-DistributedOn_EDIT
- : 'DISTRIBUTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'DISTRIBUTED' 'ON' ParenthesizedColumnList_EDIT
- ;
-
-SortedOn
- : 'SORTED' 'ON' ParenthesizedColumnList
- ;
-
-SortedOn_EDIT
- : 'SORTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- | 'SORTED' 'ON' ParenthesizedColumnList_EDIT
- ;
-
-OptionalSortedBy
- :
- | 'SORTED' 'BY' ParenthesizedSortList
- ;
-
-OptionalSortedBy_EDIT
- : 'SORTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'SORTED' 'BY' ParenthesizedSortList_EDIT
- ;
-
-ParenthesizedSortList
- : '(' SortList ')'
- ;
-
-ParenthesizedSortList_EDIT
- : '(' SortList_EDIT RightParenthesisOrError
- ;
-
-SortList
- : SortIdentifier
- | SortList ',' SortIdentifier
- ;
-
-SortList_EDIT
- : SortIdentifier_EDIT
- | SortIdentifier_EDIT ',' SortList
- | SortList ',' SortIdentifier_EDIT
- | SortList ',' SortIdentifier_EDIT ',' SortList
- ;
-
-SortIdentifier
- : ColumnIdentifier OptionalAscOrDesc
- ;
-
-SortIdentifier_EDIT
- : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
-   {
-     parser.checkForKeywords($2);
-   }
- | ColumnIdentifier_EDIT OptionalAscOrDesc
- | AnyCursor OptionalAscOrDesc
-   {
-     parser.suggestColumns();
-   }
- ;
-
-OptionalSkewedBy
- :
- | SkewedBy
- ;
-
-SkewedBy
- : 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList  -> { suggestKeywords: ['STORED AS DIRECTORIES'] }
- | 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList 'STORED_AS_DIRECTORIES' // Hack otherwise ambiguous with OptionalStoredAsOrBy
- ;
-
-SkewedBy_EDIT
- : 'SKEWED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- ;
-
-ParenthesizedSkewedValueList
- : '(' SkewedValueList ')'
- ;
-
-SkewedValueList
- : ParenthesizedSimpleValueList
- | SkewedValueList ',' ParenthesizedSimpleValueList
- ;
-
-OptionalRowFormat
- :
- | RowFormat
- ;
-
-RowFormat
- : 'ROW' 'FORMAT' RowFormatSpec
-   {
-     $$ = $3
-   }
- ;
-
-RowFormat_EDIT
- : 'ROW' 'CURSOR'
-   {
-     parser.suggestKeywords(['FORMAT']);
-   }
- | 'ROW' 'FORMAT' 'CURSOR'
-   {
-     parser.suggestKeywords(['DELIMITED', 'SERDE']);
-   }
- | 'ROW' 'FORMAT' RowFormatSpec_EDIT
- ;
-
-OptionalStoredAsOrBy
- :
- | StoredAsOrBy
- ;
-
-StoredAsOrBy
- : StoredAs
- | 'STORED' 'BY' QuotedValue
-  {
-    $$ = { storedBy: true }
-  }
- ;
-
-StoredAsOrBy_EDIT
- : 'STORED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS', 'BY']);
-   }
- | StoredAs_EDIT
- ;
-
-OptionalStoredAs
- :           -> { suggestKeywords: ['STORED AS'] }
- | StoredAs
- ;
-
-StoredAs
- : 'STORED' 'AS' FileFormat
- ;
-
-StoredAs_EDIT
- : 'STORED' 'AS' 'CURSOR'
-   {
-     parser.suggestFileFormats();
-   }
- ;
-
-FileFormat
- : 'AVRO'
- | 'INPUTFORMAT' QuotedValue 'OUTPUTFORMAT' QuotedValue
- | 'JSONFILE'
- | 'ORC'
- | 'PARQUET'
- | 'RCFILE'
- | 'SEQUENCEFILE'
- | 'TEXTFILE'
- ;
-
-RowFormatSpec
- : DelimitedRowFormat
- | 'SERDE' QuotedValue
- ;
-
-RowFormatSpec_EDIT
- : DelimitedRowFormat_EDIT
- ;
-
-DelimitedRowFormat
- : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
-   {
-     if (!$2 && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
-     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
-     } else if (!$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$6) {
-       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
-     }
-   }
- ;
-
-DelimitedRowFormat_EDIT
- : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
- ;
-
-OptionalFieldsTerminatedBy
- :
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
- ;
-
-OptionalFieldsTerminatedBy_EDIT
- : 'FIELDS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalCollectionItemsTerminatedBy
- :
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalCollectionItemsTerminatedBy_EDIT
- : 'COLLECTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['ITEMS TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalMapKeysTerminatedBy
- :
- | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalMapKeysTerminatedBy_EDIT
- : 'MAP' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEYS TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalLinesTerminatedBy
- :
- | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalLinesTerminatedBy_EDIT
- : 'LINES' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'LINES' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalNullDefinedAs
- :
- | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
- ;
-
-OptionalNullDefinedAs_EDIT
- : 'NULL' 'CURSOR'
-   {
-     parser.suggestKeywords(['DEFINED AS']);
-   }
- | 'NULL' 'DEFINED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- ;
-
-OptionalWithSerdeproperties
- :
- | WithSerdeproperties
- ;
-
-WithSerdeproperties
- :'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-WithSerdeproperties_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- ;
-
-OptionalTblproperties
- :
- | TblProperties
- ;
-
-TblProperties
- : 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-OptionalAsSelectStatement
- :
- | AsSelectStatement
- ;
-
-AsSelectStatement
- : 'AS' CommitLocations QuerySpecification
- ;
-
-AsSelectStatement_EDIT
- : 'AS' CommitLocations 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | 'AS' CommitLocations QuerySpecification_EDIT
- ;
-
-CommitLocations
- : /* empty */
-   {
-     parser.commitLocations();
-   }
- ;
-
-MaterializedViewDefinition
- : 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier
-    OptionalDisableRewrite OptionalComment OptionalPartitionedOn OptionalClusteredOrDistributedOn
-    OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties
-    AsSelectStatement
- ;
-
-MaterializedViewDefinition_EDIT
- : 'CREATE' 'MATERIALIZED' 'CURSOR'
-   {
-     parser.suggestKeywords(['VIEW']);
-   }
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties 'CURSOR'
-   {
-     parser.suggestKeywordsForOptionalsLR([undefined, $12, $11, $10, $9, $8, $7, $6, $5], [
-       { value: 'AS SELECT', weight: 1 },
-       { value: 'TBLPROPERTIES', weight: 2 },
-       { value: 'LOCATION', weight: 3 },
-       [{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }],
-       [{ value: 'CLUSTERED ON', weight: 5 }, { value: 'DISTRIBUTED ON', weight: 5 }],
-       { value: 'PARTITIONED ON', weight: 6 },
-       { value: 'COMMENT', weight: 7 },
-       { value: 'DISABLE REWRITE', weight: 8 }
-     ]);
-   }
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier DisableRewrite_EDIT OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   PartitionedOn_EDIT OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn ClusteredOrDistributedOn_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
-   OptionalTblproperties
- | 'CREATE' 'MATERIALIZED' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalDisableRewrite OptionalComment
-   OptionalPartitionedOn OptionalClusteredOrDistributedOn OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties AsSelectStatement_EDIT
- ;
-
-
-OptionalDisableRewrite
- :
- | 'DISABLE' 'REWRITE'
- ;
-
-DisableRewrite_EDIT
- : 'DISABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['REWRITE']);
-   }
- ;
-
-ViewDefinition
- : 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
- ;
-
-ViewDefinition_EDIT
- : 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment OptionalTblproperties
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'CURSOR'
-   {
-     var keywords = [{value: 'AS', weight: 1 }];
-     if (!$7) {
-       keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
-       if (!$6) {
-         keywords.push({ value: 'COMMENT', weight: 3 });
-       }
-     }
-     parser.suggestKeywords(keywords);
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification_EDIT
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
- ;
-
-FunctionDefinition
- : TemporaryFunction
- ;
-
-FunctionDefinition_EDIT
- : TemporaryFunction_EDIT
- ;
-
-FunctionDefinition
- : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing
- ;
-
-FunctionDefinition_EDIT
- : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing_EDIT
- | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['USING']);
-     } else {
-       parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
-     }
-   }
- ;
-
-TemporaryFunction
- : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'AS' SingleQuotedValue
- ;
-
-TemporaryFunction_EDIT
- : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- ;
-
-FunctionReference
- : SingleQuotedValue
- ;
-
-FunctionReference_EDIT
- : SingleQuotedValue_EDIT
-   {
-     parser.suggestFunctions();
-     parser.suggestAggregateFunctions();
-     parser.suggestAnalyticFunctions();
-   }
- ;
-
-OptionalUsing
- :
- | 'USING' OneOrMoreFunctionResources
- ;
-
-OptionalUsing_EDIT
- : 'USING' 'CURSOR'
-   {
-     parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
-   }
- ;
-
-OneOrMoreFunctionResources
- : FunctionResource
- | OneOrMoreFunctionResources ',' FunctionResource
- ;
-
-FunctionResource
- : FunctionResourceType SingleQuotedValue
- ;
-
-FunctionResourceType
- : 'ARCHIVE'
- | 'FILE'
- | 'JAR'
- ;
-
-OptionalParenthesizedViewColumnList
- :
- | ParenthesizedViewColumnList
- ;
-
-ParenthesizedViewColumnList
- : '(' ViewColumnList ')'
- ;
-
-ParenthesizedViewColumnList_EDIT
- : '(' ViewColumnList_EDIT RightParenthesisOrError
-   {
-     if (!$2) {
-       parser.suggestKeywords(['COMMENT']);
-     }
-   }
- ;
-
-ViewColumnList
- : ColumnReference OptionalComment
- | ViewColumnList ',' ColumnReference OptionalComment
- ;
-
-ViewColumnList_EDIT
- : ColumnReference OptionalComment 'CURSOR'                                        -> $2
- | ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList                     -> $2
- | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR'                     -> $4
- | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList  -> $4
- ;
-
-RoleDefinition
- : 'CREATE' 'ROLE' RegularIdentifier
- ;
-
-IndexDefinition
- : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat
-   OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment
- ;
-
-IndexDefinition_EDIT
- : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['ON TABLE']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
-   {
-     if ($13 && parser.yy.result.suggestKeywords && parser.yy.result.suggestKeywords.length === 2) {
-       parser.suggestKeywords(['AS']);
-     }
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment 'CURSOR'
-   {
-     if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'WITH DEFERRED REBUILD', weight: 7 }, { value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if ($13 && $13.suggestKeywords && !$14 && !$15 && !$16) {
-       parser.suggestKeywords(parser.createWeightedKeywords($13.suggestKeywords, 5).concat([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]));
-     } else if (!$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$16 && !$17) {
-       parser.suggestKeywords([{ value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$17) {
-       parser.suggestKeywords([{ value: 'COMMENT', weight: 1 }]);
-     }
-   }
- ;
-
-ExistingTable
- : SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-ExistingTable_EDIT
- : SchemaQualifiedTableIdentifier_EDIT
- ;
-
-IndexType
- : QuotedValue
- ;
-
-IndexType_EDIT
- : QuotedValue_EDIT
-   {
-     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
-   }
- ;
-
-OptionalWithDeferredRebuild
- :
- | 'WITH' 'DEFERRED' 'REBUILD'
- ;
-
-OptionalWithDeferredRebuild_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['DEFERRED REBUILD']);
-   }
- | 'WITH' 'DEFERRED' 'CURSOR'
-   {
-     parser.suggestKeywords(['REBUILD']);
-   }
- ;
-
-OptionalIdxProperties
- :
- | 'IDXPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-OptionalInTable
- :
- | 'IN' 'TABLE' SchemaQualifiedTableIdentifier
- ;
-
-OptionalInTable_EDIT
- : 'IN' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'IN' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'IN' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-
-ParenthesizedIndexColumnList
- : '(' IndexColumnList ')'
- ;
-
-ParenthesizedIndexColumnList_EDIT
- : '(' IndexColumnList_EDIT RightParenthesisOrError
-   {
-     parser.suggestColumns();
-   }
- ;
-
-IndexColumnList
- : ColumnReference
- | IndexColumnList ',' ColumnReference
- ;
-
-IndexColumnList_EDIT
- : AnyCursor
- | IndexColumnList ',' AnyCursor
- | AnyCursor ',' IndexColumnList
- | IndexColumnList ',' AnyCursor ',' IndexColumnList
- ;
-
-MacroDefinition
- : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression
- ;
-
-MacroDefinition_EDIT
- : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT ValueExpression
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments 'CURSOR'
-   {
-     parser.suggestFunctions();
-   }
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression_EDIT
- ;
-
-MacroArguments
- : '(' ')'
- | '(' MacroArgumentList ')'
- ;
-
-MacroArguments_EDIT
- : '(' MacroArgumentList_EDIT RightParenthesisOrError
- ;
-
-
-MacroArgumentList
- : MacroArgument
- | MacroArgumentList ',' MacroArgument
- ;
-
-MacroArgumentList_EDIT
- : MacroArgument_EDIT
- | MacroArgumentList ',' MacroArgument_EDIT
- | MacroArgument_EDIT ',' MacroArgumentList
- | MacroArgumentList ',' MacroArgument_EDIT ',' MacroArgumentList
- ;
-
-MacroArgument
- : RegularIdentifier ColumnDataType
- ;
-
-MacroArgument_EDIT
- : RegularIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | RegularIdentifier ColumnDataType_EDIT
- ;

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

@@ -3,13 +3,24 @@
   "autocomplete": [
     "../generic/autocomplete_header.jison",
     "abort/abort_transactions.jison",
-    "common/sql_table_constraint.jison",
+    "common/table_constraint.jison",
     "alter/alter_common.jison",
     "alter/alter_database.jison",
     "alter/alter_index.jison",
     "alter/alter_materialized_view.jison",
     "alter/alter_table.jison",
     "alter/alter_view.jison",
+    "analyze/analyze_table.jison",
+    "create/create_common.jison",
+    "create/create_database.jison",
+    "create/create_function.jison",
+    "create/create_index.jison",
+    "create/create_materialized_view.jison",
+    "create/create_role.jison",
+    "create/create_table.jison",
+    "create/create_temporary_function.jison",
+    "create/create_temporary_macro.jison",
+    "create/create_view.jison",
     "delete/delete.jison",
     "drop/drop_common.jison",
     "drop/drop_database.jison",
@@ -21,6 +32,7 @@
     "drop/drop_temporary_function.jison",
     "drop/drop_temporary_macro.jison",
     "drop/drop_view.jison",
+    "explain/explain.jison",
     "reload/reload.jison",
     "show/show_columns.jison",
     "show/show_common.jison",
@@ -66,8 +78,6 @@
     "udf/sql_extract.jison",
     "../generic/use/use.jison",
     "../generic/sql_valueExpression.jison",
-    "sql_analyze.jison",
-    "sql_create.jison",
     "sql_error.jison",
     "sql_grant.jison",
     "sql_insert.jison",
@@ -81,13 +91,24 @@
   "syntax": [
     "../generic/syntax_header.jison",
     "abort/abort_transactions.jison",
-    "common/sql_table_constraint.jison",
+    "common/table_constraint.jison",
     "alter/alter_common.jison",
     "alter/alter_database.jison",
     "alter/alter_index.jison",
     "alter/alter_materialized_view.jison",
     "alter/alter_table.jison",
     "alter/alter_view.jison",
+    "analyze/analyze_table.jison",
+    "create/create_common.jison",
+    "create/create_database.jison",
+    "create/create_function.jison",
+    "create/create_index.jison",
+    "create/create_materialized_view.jison",
+    "create/create_role.jison",
+    "create/create_table.jison",
+    "create/create_temporary_function.jison",
+    "create/create_temporary_macro.jison",
+    "create/create_view.jison",
     "delete/delete.jison",
     "drop/drop_common.jison",
     "drop/drop_database.jison",
@@ -99,6 +120,7 @@
     "drop/drop_temporary_function.jison",
     "drop/drop_temporary_macro.jison",
     "drop/drop_view.jison",
+    "explain/explain.jison",
     "reload/reload.jison",
     "show/show_columns.jison",
     "show/show_common.jison",
@@ -144,8 +166,6 @@
     "udf/sql_extract.jison",
     "../generic/use/use.jison",
     "../generic/sql_valueExpression.jison",
-    "sql_analyze.jison",
-    "sql_create.jison",
     "sql_grant.jison",
     "sql_insert.jison",
     "sql_load.jison",

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

@@ -25,3 +25,49 @@ TableConstraint_EDIT
    }
  | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
  ;
+
+ForeignKeySpecification
+ : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyOrNorely
+   {
+     parser.addTablePrimary($5);
+   }
+ ;
+
+ForeignKeySpecification_EDIT
+ : 'FOREIGN' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEY']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList_EDIT
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'CURSOR'
+   {
+     parser.suggestKeywords(['REFERENCES']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' 'CURSOR'
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier_EDIT
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList_EDIT
+   {
+     parser.addTablePrimary($5);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'CURSOR'
+   {
+     parser.addTablePrimary($5);
+     parser.suggestKeywords(['DISABLE NOVALIDATE']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'CURSOR'
+   {
+     parser.addTablePrimary($5);
+     parser.suggestKeywords(['NOVALIDATE']);
+   }
+ | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyOrNorely 'CURSOR'
+   {
+     parser.addTablePrimary($5);
+     if (!$9) {
+       parser.suggestKeywords(['NORELY', 'RELY']);
+     }
+   }
+ ;

+ 698 - 0
desktop/core/src/desktop/js/parse/jison/sql/presto/create/create_common.jison

@@ -0,0 +1,698 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+DataDefinition_EDIT
+ : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'CURSOR'
+   {
+     if ($4) {
+       parser.suggestKeywords(['TABLE']);
+     } else {
+       if ($2 && !$3) {
+         parser.suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']);
+       } else if (!$2 && !$3) {
+         parser.suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'TRANSACTIONAL TABLE', 'VIEW']);
+       } else if ($3) {
+         parser.suggestKeywords(['TABLE']);
+       }
+     }
+   }
+ ;
+
+OptionalComment
+ :
+ | Comment
+ ;
+
+Comment
+ : 'COMMENT' QuotedValue
+ ;
+
+ParenthesizedPropertyAssignmentList
+ : '(' PropertyAssignmentList ')'
+ ;
+
+PropertyAssignmentList
+ : PropertyAssignment
+ | PropertyAssignmentList ',' PropertyAssignment
+ ;
+
+PropertyAssignment
+ : QuotedValue '=' UnsignedValueSpecification
+ ;
+
+ParenthesizedColumnSpecificationList
+ : '(' ColumnSpecificationList ')'                              -> $2
+ | '(' ColumnSpecificationList ',' TableConstraints ')'  -> $2
+ ;
+
+ParenthesizedColumnSpecificationList_EDIT
+ : '(' ColumnSpecificationList_EDIT RightParenthesisOrError
+ | '(' ColumnSpecificationList ',' TableConstraints_EDIT RightParenthesisOrError
+ | '(' ColumnSpecificationList ',' 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords([{ value: 'PRIMARY KEY', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }]);
+   }
+ ;
+
+ColumnSpecificationList
+ : ColumnSpecification                              -> [$1]
+ | ColumnSpecificationList ',' ColumnSpecification  -> $1.concat($3)
+ ;
+
+ColumnSpecificationList_EDIT
+ : ColumnSpecification_EDIT
+ | ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecification 'CURSOR'
+   {
+     parser.checkForKeywords($1);
+   }
+ | ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
+   {
+     parser.checkForKeywords($1);
+   }
+ | ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
+   {
+     parser.checkForKeywords($3);
+   }
+ | ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
+   {
+     parser.checkForKeywords($3);
+   }
+ ;
+
+ColumnSpecification
+ : ColumnIdentifier ColumnDataType OptionalColumnOptions
+   {
+     $$ = $1;
+     $$.type = $2;
+     var keywords = [];
+     if (!$3['comment']) {
+       keywords.push('COMMENT');
+       if ($2.toLowerCase() === 'double') {
+         keywords.push({ value: 'PRECISION', weight: 2 });
+       }
+     }
+     if (keywords.length > 0) {
+       $$.suggestKeywords = keywords;
+     }
+   }
+ ;
+
+ColumnSpecification_EDIT
+ : ColumnIdentifier 'CURSOR' OptionalColumnOptions
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
+ ;
+
+OptionalColumnOptions
+ :                      -> {}
+ | ColumnOptions
+ ;
+
+ColumnOptions
+ : ColumnOption
+   {
+     $$ = {};
+     $$[$1] = true;
+   }
+ | ColumnOptions ColumnOption
+   {
+     $1[$2] = true;
+   }
+ ;
+
+ColumnOption
+ : Comment                                                   -> 'comment'
+ ;
+
+ColumnDataType
+ : PrimitiveType
+ | ArrayType
+ | MapType
+ | StructType
+ | UnionType
+ | ArrayType_INVALID
+ | MapType_INVALID
+ | StructType_INVALID
+ | UnionType_INVALID
+ ;
+
+ColumnDataType_EDIT
+ : ArrayType_EDIT
+ | MapType_EDIT
+ | StructType_EDIT
+ | UnionType_EDIT
+ ;
+
+ArrayType
+ : 'ARRAY' '<' ColumnDataType '>'
+ ;
+
+ArrayType_INVALID
+ : 'ARRAY' '<' '>'
+ ;
+
+ArrayType_EDIT
+ : 'ARRAY' '<' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
+ ;
+
+MapType
+ : 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
+ ;
+
+MapType_INVALID
+ : 'MAP' '<' '>'
+ ;
+
+MapType_EDIT
+ : 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
+ | 'MAP' '<' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getTypeKeywords());
+   }
+ | 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | 'MAP' '<' ',' AnyCursor GreaterThanOrError
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ ;
+
+StructType
+ : 'STRUCT' '<' StructDefinitionList '>'
+ ;
+
+StructType_INVALID
+ : 'STRUCT' '<' '>'
+ ;
+
+StructType_EDIT
+ : 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
+ ;
+
+StructDefinitionList
+ : StructDefinition
+ | StructDefinitionList ',' StructDefinition
+ ;
+
+StructDefinitionList_EDIT
+ : StructDefinition_EDIT
+ | StructDefinition_EDIT Commas
+ | StructDefinition_EDIT Commas StructDefinitionList
+ | StructDefinitionList ',' StructDefinition_EDIT
+ | StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
+ ;
+
+StructDefinition
+ : RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
+ ;
+
+StructDefinition_EDIT
+ : Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
+   {
+     parser.suggestKeywords(['COMMENT']);
+   }
+ | Commas RegularOrBacktickedIdentifier ':' AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
+ | RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
+   {
+     parser.suggestKeywords(['COMMENT']);
+   }
+ | RegularOrBacktickedIdentifier ':' AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
+ ;
+
+UnionType
+ : 'UNIONTYPE' '<' ColumnDataTypeList '>'
+ ;
+
+UnionType_INVALID
+ : 'UNIONTYPE' '<' '>'
+ ;
+
+UnionType_EDIT
+ : 'UNIONTYPE' '<' ColumnDataTypeList_EDIT GreaterThanOrError
+ ;
+
+ColumnDataTypeList
+ : ColumnDataType
+ | ColumnDataTypeList ',' ColumnDataType
+ ;
+
+ColumnDataTypeList_EDIT
+ : ColumnDataTypeListInner_EDIT
+ | ColumnDataTypeListInner_EDIT Commas
+ | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
+ | ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
+ | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
+ ;
+
+ColumnDataTypeListInner_EDIT
+ : Commas AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | Commas ColumnDataType_EDIT
+ | AnyCursor
+   {
+     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
+   }
+ | ColumnDataType_EDIT
+ ;
+
+GreaterThanOrError
+ : '>'
+ | error
+ ;
+
+TableConstraints
+ : PrimaryKeySpecification
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ ;
+
+TableConstraints_EDIT
+ : PrimaryKeySpecification_EDIT
+ | PrimaryKeySpecification ',' 'CURSOR'
+   {
+     parser.suggestKeywords(['CONSTRAINT']);
+   }
+ | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['FOREIGN KEY']);
+   }
+ | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
+ | PrimaryKeySpecification_EDIT ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
+   {
+     parser.suggestKeywords(['FOREIGN KEY']);
+   }
+ | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
+ | 'CURSOR' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
+   {
+     parser.suggestKeywords(['PRIMARY KEY']);
+   }
+ ;
+
+PrimaryKeySpecification
+ : PrimaryKey ParenthesizedColumnList 'DISABLE' 'NOVALIDATE'
+ ;
+
+PrimaryKeySpecification_EDIT
+ : PrimaryKey_EDIT
+ | PrimaryKey ParenthesizedColumnList_EDIT
+ | PrimaryKey ParenthesizedColumnList 'CURSOR'
+   {
+     parser.suggestKeywords(['DISABLE NOVALIDATE']);
+   }
+ | PrimaryKey ParenthesizedColumnList 'DISABLE' 'CURSOR'
+   {
+     parser.suggestKeywords(['NOVALIDATE']);
+   }
+ | PrimaryKey ParenthesizedColumnList_EDIT 'DISABLE' 'NOVALIDATE'
+ ;
+
+OptionalRelyOrNorely
+ :
+ | 'RELY'
+ | 'NORELY'
+ ;
+
+PrimaryKey
+ : 'PRIMARY' 'KEY'
+ ;
+
+PrimaryKey_EDIT
+ : 'PRIMARY' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEY']);
+   }
+ ;
+
+ClusteredBy
+ : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ ;
+
+ClusteredBy_EDIT
+ : 'CLUSTERED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
+   {
+     if (!$4) {
+       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
+     } else {
+       parser.suggestKeywords(['INTO']);
+     }
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
+   {
+     parser.suggestKeywords(['BUCKETS']);
+   }
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
+ | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
+ ;
+
+OptionalSortedBy
+ :
+ | 'SORTED' 'BY' ParenthesizedSortList
+ ;
+
+OptionalSortedBy_EDIT
+ : 'SORTED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'SORTED' 'BY' ParenthesizedSortList_EDIT
+ ;
+
+ParenthesizedSortList
+ : '(' SortList ')'
+ ;
+
+ParenthesizedSortList_EDIT
+ : '(' SortList_EDIT RightParenthesisOrError
+ ;
+
+SortList
+ : SortIdentifier
+ | SortList ',' SortIdentifier
+ ;
+
+SortList_EDIT
+ : SortIdentifier_EDIT
+ | SortIdentifier_EDIT ',' SortList
+ | SortList ',' SortIdentifier_EDIT
+ | SortList ',' SortIdentifier_EDIT ',' SortList
+ ;
+
+SortIdentifier
+ : ColumnIdentifier OptionalAscOrDesc
+ ;
+
+SortIdentifier_EDIT
+ : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
+   {
+     parser.checkForKeywords($2);
+   }
+ | ColumnIdentifier_EDIT OptionalAscOrDesc
+ | AnyCursor OptionalAscOrDesc
+   {
+     parser.suggestColumns();
+   }
+ ;
+
+ParenthesizedSkewedValueList
+ : '(' SkewedValueList ')'
+ ;
+
+SkewedValueList
+ : ParenthesizedSimpleValueList
+ | SkewedValueList ',' ParenthesizedSimpleValueList
+ ;
+
+OptionalRowFormat
+ :
+ | RowFormat
+ ;
+
+RowFormat
+ : 'ROW' 'FORMAT' RowFormatSpec
+   {
+     $$ = $3
+   }
+ ;
+
+RowFormat_EDIT
+ : 'ROW' 'CURSOR'
+   {
+     parser.suggestKeywords(['FORMAT']);
+   }
+ | 'ROW' 'FORMAT' 'CURSOR'
+   {
+     parser.suggestKeywords(['DELIMITED', 'SERDE']);
+   }
+ | 'ROW' 'FORMAT' RowFormatSpec_EDIT
+ ;
+
+OptionalStoredAsOrBy
+ :
+ | StoredAsOrBy
+ ;
+
+StoredAsOrBy
+ : StoredAs
+ | 'STORED' 'BY' QuotedValue
+  {
+    $$ = { storedBy: true }
+  }
+ ;
+
+StoredAsOrBy_EDIT
+ : 'STORED' 'CURSOR'
+   {
+     parser.suggestKeywords(['AS', 'BY']);
+   }
+ | StoredAs_EDIT
+ ;
+
+OptionalStoredAs
+ :           -> { suggestKeywords: ['STORED AS'] }
+ | StoredAs
+ ;
+
+StoredAs
+ : 'STORED' 'AS' FileFormat
+ ;
+
+StoredAs_EDIT
+ : 'STORED' 'AS' 'CURSOR'
+   {
+     parser.suggestFileFormats();
+   }
+ ;
+
+FileFormat
+ : 'AVRO'
+ | 'INPUTFORMAT' QuotedValue 'OUTPUTFORMAT' QuotedValue
+ | 'JSONFILE'
+ | 'ORC'
+ | 'PARQUET'
+ | 'RCFILE'
+ | 'SEQUENCEFILE'
+ | 'TEXTFILE'
+ ;
+
+RowFormatSpec
+ : DelimitedRowFormat
+ | 'SERDE' QuotedValue
+ ;
+
+RowFormatSpec_EDIT
+ : DelimitedRowFormat_EDIT
+ ;
+
+DelimitedRowFormat
+ : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
+   {
+     if (!$2 && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
+     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
+     } else if (!$3 && !$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$4 && !$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$5 && !$6) {
+       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
+     } else if (!$6) {
+       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
+     }
+   }
+ ;
+
+DelimitedRowFormat_EDIT
+ : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
+   OptionalLinesTerminatedBy OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
+ | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
+   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
+ ;
+
+OptionalFieldsTerminatedBy
+ :
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
+ ;
+
+OptionalFieldsTerminatedBy_EDIT
+ : 'FIELDS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalCollectionItemsTerminatedBy
+ :
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalCollectionItemsTerminatedBy_EDIT
+ : 'COLLECTION' 'CURSOR'
+   {
+     parser.suggestKeywords(['ITEMS TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalMapKeysTerminatedBy
+ :
+ | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalMapKeysTerminatedBy_EDIT
+ : 'MAP' 'CURSOR'
+   {
+     parser.suggestKeywords(['KEYS TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalLinesTerminatedBy
+ :
+ | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
+ ;
+
+OptionalLinesTerminatedBy_EDIT
+ : 'LINES' 'CURSOR'
+   {
+     parser.suggestKeywords(['TERMINATED BY']);
+   }
+ | 'LINES' 'TERMINATED' 'CURSOR'
+   {
+     parser.suggestKeywords(['BY']);
+   }
+ ;
+
+OptionalNullDefinedAs
+ :
+ | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
+ ;
+
+OptionalNullDefinedAs_EDIT
+ : 'NULL' 'CURSOR'
+   {
+     parser.suggestKeywords(['DEFINED AS']);
+   }
+ | 'NULL' 'DEFINED' 'CURSOR'
+   {
+     parser.suggestKeywords(['AS']);
+   }
+ ;
+
+OptionalWithSerdeproperties
+ :
+ | WithSerdeproperties
+ ;
+
+WithSerdeproperties
+ :'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+WithSerdeproperties_EDIT
+ : 'WITH' 'CURSOR'
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES']);
+   }
+ ;
+
+OptionalTblproperties
+ :
+ | TblProperties
+ ;
+
+TblProperties
+ : 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
+ ;
+
+AsSelectStatement
+ : 'AS' CommitLocations QuerySpecification
+ ;
+
+AsSelectStatement_EDIT
+ : 'AS' CommitLocations 'CURSOR'
+   {
+     parser.suggestKeywords(['SELECT']);
+   }
+ | 'AS' CommitLocations QuerySpecification_EDIT
+ ;
+
+CommitLocations
+ : /* empty */
+   {
+     parser.commitLocations();
+   }
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/presto/create/create_database_no_db.jison

@@ -0,0 +1,19 @@
+// 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.
+
+CreateDatabase
+ : 'CREATE' DatabaseOrSchema OptionalIfNotExists
+ ;

+ 0 - 1408
desktop/core/src/desktop/js/parse/jison/sql/presto/sql_create.jison

@@ -1,1408 +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
- : CreateStatement
- ;
-
-DataDefinition_EDIT
- : CreateStatement_EDIT
- ;
-
-CreateStatement
- : DatabaseDefinition
- | TableDefinition
- | ViewDefinition
- | RoleDefinition
- | FunctionDefinition
- | IndexDefinition
- | MacroDefinition
- ;
-
-CreateStatement_EDIT
- : DatabaseDefinition_EDIT
- | TableDefinition_EDIT
- | ViewDefinition_EDIT
- | FunctionDefinition_EDIT
- | IndexDefinition_EDIT
- | MacroDefinition_EDIT
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'CURSOR'
-   {
-     if ($4) {
-       parser.suggestKeywords(['TABLE']);
-     } else {
-       if ($2 && !$3) {
-         parser.suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']);
-       } else if (!$2 && !$3) {
-         parser.suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'TRANSACTIONAL TABLE', 'VIEW']);
-       } else if ($3) {
-         parser.suggestKeywords(['TABLE']);
-       }
-     }
-   }
- ;
-
-DatabaseDefinition
- : 'CREATE' DatabaseOrSchema OptionalIfNotExists
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- ;
-
-DatabaseDefinition_EDIT
- : 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-     parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- | 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
-   {
-     parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
-   }
- ;
-
-DatabaseDefinitionOptionals
- : OptionalComment OptionalHdfsLocation OptionalDbProperties
-   {
-     var keywords = [];
-     if (!$3) {
-       keywords.push('WITH DBPROPERTIES');
-     }
-     if (!$2 && !$3) {
-       keywords.push('LOCATION');
-     }
-     if (!$1 && !$2 && !$3) {
-       keywords.push('COMMENT');
-     }
-     if (keywords.length > 0) {
-       parser.suggestKeywords(keywords);
-     }
-   }
- ;
-
-DatabaseDefinitionOptionals_EDIT
- : OptionalComment_INVALID OptionalHdfsLocation OptionalDbProperties
- | OptionalComment HdfsLocation_EDIT OptionalDbProperties
- ;
-
-OptionalComment
- :
- | Comment
- ;
-
-Comment
- : 'COMMENT' QuotedValue
- ;
-
-OptionalComment_INVALID
- : Comment_INVALID
- ;
-
-Comment_INVALID
- : 'COMMENT' SINGLE_QUOTE
- | 'COMMENT' DOUBLE_QUOTE
- | 'COMMENT' SINGLE_QUOTE VALUE
- | 'COMMENT' DOUBLE_QUOTE VALUE
- ;
-
-
-OptionalDbProperties
- :
- | DbProperties
- ;
-
-DbProperties
- : 'WITH' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList
- | 'WITH' 'DBPROPERTIES'
- | 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['DBPROPERTIES']);
-   }
- ;
-
-ParenthesizedPropertyAssignmentList
- : '(' PropertyAssignmentList ')'
- ;
-
-PropertyAssignmentList
- : PropertyAssignment
- | PropertyAssignmentList ',' PropertyAssignment
- ;
-
-PropertyAssignment
- : QuotedValue '=' UnsignedValueSpecification
- ;
-
-TableDefinition
- : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart
- ;
-
-TableDefinition_EDIT
- : 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' OptionalTemporary OptionalTransactional OptionalExternal 'TABLE' OptionalIfNotExists_EDIT
- ;
-
-TableDefinitionRightPart
- : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- ;
-
-TableDefinitionRightPart_EDIT
- : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   ClusteredBy_EDIT OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy SkewedBy_EDIT OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy RowFormat_EDIT OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat StoredAsOrBy_EDIT
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   WithSerdeproperties_EDIT OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties HdfsLocation_EDIT OptionalTblproperties OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalAsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy
-   OptionalClusteredBy OptionalSkewedBy OptionalRowFormat OptionalStoredAsOrBy
-   OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties 'CURSOR'
-   {
-     var keywords = [];
-     if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-       keywords.push({ value: 'LIKE', weight: 1 });
-     } else {
-       if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'COMMENT', weight: 10 });
-       }
-       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'PARTITIONED BY', weight: 9 });
-       }
-       if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'CLUSTERED BY', weight: 8 });
-       }
-       if (!$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'SKEWED BY', weight: 7 });
-       } else if ($5 && $5.suggestKeywords && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 7)); // Get the last optional from SKEWED BY
-       }
-       if (!$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'ROW FORMAT', weight: 6 });
-       } else if ($6 && $6.suggestKeywords && !$7 && !$8 && !$9 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($6.suggestKeywords, 6));
-       }
-       if (!$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'STORED AS', weight: 5 });
-         keywords.push({ value: 'STORED BY', weight: 5 });
-       } else if ($7 && $7.storedBy && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 4 });
-       }
-       if (!$9 && !$10) {
-         keywords.push({ value: 'LOCATION', weight: 3 });
-       }
-       if (!$10) {
-         keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
-       }
-       keywords.push({ value: 'AS', weight: 1 });
-     }
-
-     parser.suggestKeywords(keywords);
-   }
- ;
-
-TableIdentifierAndOptionalColumnSpecification
- : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
-   {
-     parser.addNewTableLocation(@1, $1, $2);
-     $$ = $2;
-   }
- ;
-
-TableIdentifierAndOptionalColumnSpecification_EDIT
- : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
- | SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
- ;
-
-OptionalColumnSpecificationsOrLike
- :
- | ParenthesizedColumnSpecificationList
- | 'LIKE' SchemaQualifiedTableIdentifier    -> []
- ;
-
-OptionalColumnSpecificationsOrLike_EDIT
- : ParenthesizedColumnSpecificationList_EDIT
- | 'LIKE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'LIKE' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-ParenthesizedColumnSpecificationList
- : '(' ColumnSpecificationList ')'                              -> $2
- | '(' ColumnSpecificationList ',' ConstraintSpecification ')'  -> $2
- ;
-
-ParenthesizedColumnSpecificationList_EDIT
- : '(' ColumnSpecificationList_EDIT RightParenthesisOrError
- | '(' ColumnSpecificationList ',' ConstraintSpecification_EDIT RightParenthesisOrError
- | '(' ColumnSpecificationList ',' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords([{ value: 'PRIMARY KEY', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }]);
-   }
- ;
-
-ColumnSpecificationList
- : ColumnSpecification                              -> [$1]
- | ColumnSpecificationList ',' ColumnSpecification  -> $1.concat($3)
- ;
-
-ColumnSpecificationList_EDIT
- : ColumnSpecification_EDIT
- | ColumnSpecification_EDIT ',' ColumnSpecificationList
- | ColumnSpecificationList ',' ColumnSpecification_EDIT
- | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
- | ColumnSpecification 'CURSOR'
-   {
-     parser.checkForKeywords($1);
-   }
- | ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
-   {
-     parser.checkForKeywords($1);
-   }
- | ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
-   {
-     parser.checkForKeywords($3);
-   }
- | ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
-   {
-     parser.checkForKeywords($3);
-   }
- ;
-
-ColumnSpecification
- : ColumnIdentifier ColumnDataType OptionalColumnOptions
-   {
-     $$ = $1;
-     $$.type = $2;
-     var keywords = [];
-     if (!$3['comment']) {
-       keywords.push('COMMENT');
-       if ($2.toLowerCase() === 'double') {
-         keywords.push({ value: 'PRECISION', weight: 2 });
-       }
-     }
-     if (keywords.length > 0) {
-       $$.suggestKeywords = keywords;
-     }
-   }
- ;
-
-ColumnSpecification_EDIT
- : ColumnIdentifier 'CURSOR' OptionalColumnOptions
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
- ;
-
-OptionalColumnOptions
- :                      -> {}
- | ColumnOptions
- ;
-
-ColumnOptions
- : ColumnOption
-   {
-     $$ = {};
-     $$[$1] = true;
-   }
- | ColumnOptions ColumnOption
-   {
-     $1[$2] = true;
-   }
- ;
-
-ColumnOption
- : Comment                                                   -> 'comment'
- ;
-
-ColumnDataType
- : PrimitiveType
- | ArrayType
- | MapType
- | StructType
- | UnionType
- | ArrayType_INVALID
- | MapType_INVALID
- | StructType_INVALID
- | UnionType_INVALID
- ;
-
-ColumnDataType_EDIT
- : ArrayType_EDIT
- | MapType_EDIT
- | StructType_EDIT
- | UnionType_EDIT
- ;
-
-ArrayType
- : 'ARRAY' '<' ColumnDataType '>'
- ;
-
-ArrayType_INVALID
- : 'ARRAY' '<' '>'
- ;
-
-ArrayType_EDIT
- : 'ARRAY' '<' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
- ;
-
-MapType
- : 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
- ;
-
-MapType_INVALID
- : 'MAP' '<' '>'
- ;
-
-MapType_EDIT
- : 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
- | 'MAP' '<' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-   }
- | 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | 'MAP' '<' ',' AnyCursor GreaterThanOrError
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- ;
-
-StructType
- : 'STRUCT' '<' StructDefinitionList '>'
- ;
-
-StructType_INVALID
- : 'STRUCT' '<' '>'
- ;
-
-StructType_EDIT
- : 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
- ;
-
-StructDefinitionList
- : StructDefinition
- | StructDefinitionList ',' StructDefinition
- ;
-
-StructDefinitionList_EDIT
- : StructDefinition_EDIT
- | StructDefinition_EDIT Commas
- | StructDefinition_EDIT Commas StructDefinitionList
- | StructDefinitionList ',' StructDefinition_EDIT
- | StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
- ;
-
-StructDefinition
- : RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
- ;
-
-StructDefinition_EDIT
- : Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
-   {
-     parser.suggestKeywords(['COMMENT']);
-   }
- | Commas RegularOrBacktickedIdentifier ':' AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
- | RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
-   {
-     parser.suggestKeywords(['COMMENT']);
-   }
- | RegularOrBacktickedIdentifier ':' AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
- ;
-
-UnionType
- : 'UNIONTYPE' '<' ColumnDataTypeList '>'
- ;
-
-UnionType_INVALID
- : 'UNIONTYPE' '<' '>'
- ;
-
-UnionType_EDIT
- : 'UNIONTYPE' '<' ColumnDataTypeList_EDIT GreaterThanOrError
- ;
-
-ColumnDataTypeList
- : ColumnDataType
- | ColumnDataTypeList ',' ColumnDataType
- ;
-
-ColumnDataTypeList_EDIT
- : ColumnDataTypeListInner_EDIT
- | ColumnDataTypeListInner_EDIT Commas
- | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
- | ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
- | ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
- ;
-
-ColumnDataTypeListInner_EDIT
- : Commas AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | Commas ColumnDataType_EDIT
- | AnyCursor
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | ColumnDataType_EDIT
- ;
-
-GreaterThanOrError
- : '>'
- | error
- ;
-
-ConstraintSpecification
- : PrimaryKeySpecification
- | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
- | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
- ;
-
-ConstraintSpecification_EDIT
- : PrimaryKeySpecification_EDIT
- | PrimaryKeySpecification ',' 'CURSOR'
-   {
-     parser.suggestKeywords(['CONSTRAINT']);
-   }
- | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FOREIGN KEY']);
-   }
- | PrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
- | PrimaryKeySpecification_EDIT ',' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
- | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['FOREIGN KEY']);
-   }
- | 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification_EDIT
- | 'CURSOR' 'CONSTRAINT' RegularOrBacktickedIdentifier ForeignKeySpecification
-   {
-     parser.suggestKeywords(['PRIMARY KEY']);
-   }
- ;
-
-PrimaryKeySpecification
- : PrimaryKey ParenthesizedColumnList 'DISABLE' 'NOVALIDATE'
- ;
-
-PrimaryKeySpecification_EDIT
- : PrimaryKey_EDIT
- | PrimaryKey ParenthesizedColumnList_EDIT
- | PrimaryKey ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['DISABLE NOVALIDATE']);
-   }
- | PrimaryKey ParenthesizedColumnList 'DISABLE' 'CURSOR'
-   {
-     parser.suggestKeywords(['NOVALIDATE']);
-   }
- | PrimaryKey ParenthesizedColumnList_EDIT 'DISABLE' 'NOVALIDATE'
- ;
-
-ForeignKeySpecification
- : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyNoRely
-   {
-     parser.addTablePrimary($5);
-   }
- ;
-
-ForeignKeySpecification_EDIT
- : 'FOREIGN' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEY']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList_EDIT
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['REFERENCES']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier_EDIT
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList_EDIT
-   {
-     parser.addTablePrimary($5);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     parser.suggestKeywords(['DISABLE NOVALIDATE']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     parser.suggestKeywords(['NOVALIDATE']);
-   }
- | 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyNoRely 'CURSOR'
-   {
-     parser.addTablePrimary($5);
-     if (!$9) {
-       parser.suggestKeywords(['NORELY', 'RELY']);
-     }
-   }
- ;
-
-OptionalRelyNoRely
- :
- | 'RELY'
- | 'NORELY'
- ;
-
-PrimaryKey
- : 'PRIMARY' 'KEY'
- ;
-
-PrimaryKey_EDIT
- : 'PRIMARY' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEY']);
-   }
- ;
-
-OptionalPartitionedBy
- :
- | PartitionedBy
- ;
-
-PartitionedBy
- : 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList
- ;
-
-PartitionedBy_EDIT
- : 'PARTITIONED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITIONED' 'CURSOR' ParenthesizedColumnSpecificationList
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList_EDIT
- | 'PARTITIONED' ParenthesizedColumnSpecificationList_EDIT
- | 'PARTITION' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITION' 'BY' 'CURSOR'
-   {
-     parser.suggestKeywords(['HASH', 'RANGE']);
-   }
- ;
-
-LessThanOrEqualTo
- : '<'
- | 'COMPARISON_OPERATOR' // This is fine for autocompletion
- ;
-
-OptionalClusteredBy
- :
- | ClusteredBy
- ;
-
-ClusteredBy
- : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- ;
-
-ClusteredBy_EDIT
- : 'CLUSTERED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy
- | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'CURSOR'
-   {
-     if (!$4) {
-       parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]);
-     } else {
-       parser.suggestKeywords(['INTO']);
-     }
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR'
-   {
-     parser.suggestKeywords(['BUCKETS']);
-   }
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS'
- | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalSortedBy_EDIT
- ;
-
-OptionalSortedBy
- :
- | 'SORTED' 'BY' ParenthesizedSortList
- ;
-
-OptionalSortedBy_EDIT
- : 'SORTED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'SORTED' 'BY' ParenthesizedSortList_EDIT
- ;
-
-ParenthesizedSortList
- : '(' SortList ')'
- ;
-
-ParenthesizedSortList_EDIT
- : '(' SortList_EDIT RightParenthesisOrError
- ;
-
-SortList
- : SortIdentifier
- | SortList ',' SortIdentifier
- ;
-
-SortList_EDIT
- : SortIdentifier_EDIT
- | SortIdentifier_EDIT ',' SortList
- | SortList ',' SortIdentifier_EDIT
- | SortList ',' SortIdentifier_EDIT ',' SortList
- ;
-
-SortIdentifier
- : ColumnIdentifier OptionalAscOrDesc
- ;
-
-SortIdentifier_EDIT
- : ColumnIdentifier OptionalAscOrDesc 'CURSOR'
-   {
-     parser.checkForKeywords($2);
-   }
- | ColumnIdentifier_EDIT OptionalAscOrDesc
- | AnyCursor OptionalAscOrDesc
-   {
-     parser.suggestColumns();
-   }
- ;
-
-OptionalSkewedBy
- :
- | SkewedBy
- ;
-
-SkewedBy
- : 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList  -> { suggestKeywords: ['STORED AS DIRECTORIES'] }
- | 'SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList 'STORED_AS_DIRECTORIES' // Hack otherwise ambiguous with OptionalStoredAsOrBy
- ;
-
-SkewedBy_EDIT
- : 'SKEWED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['ON']);
-   }
- ;
-
-ParenthesizedSkewedValueList
- : '(' SkewedValueList ')'
- ;
-
-SkewedValueList
- : ParenthesizedSimpleValueList
- | SkewedValueList ',' ParenthesizedSimpleValueList
- ;
-
-OptionalRowFormat
- :
- | RowFormat
- ;
-
-RowFormat
- : 'ROW' 'FORMAT' RowFormatSpec
-   {
-     $$ = $3
-   }
- ;
-
-RowFormat_EDIT
- : 'ROW' 'CURSOR'
-   {
-     parser.suggestKeywords(['FORMAT']);
-   }
- | 'ROW' 'FORMAT' 'CURSOR'
-   {
-     parser.suggestKeywords(['DELIMITED', 'SERDE']);
-   }
- | 'ROW' 'FORMAT' RowFormatSpec_EDIT
- ;
-
-OptionalStoredAsOrBy
- :
- | StoredAsOrBy
- ;
-
-StoredAsOrBy
- : StoredAs
- | 'STORED' 'BY' QuotedValue
-  {
-    $$ = { storedBy: true }
-  }
- ;
-
-StoredAsOrBy_EDIT
- : 'STORED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS', 'BY']);
-   }
- | StoredAs_EDIT
- ;
-
-OptionalStoredAs
- :           -> { suggestKeywords: ['STORED AS'] }
- | StoredAs
- ;
-
-StoredAs
- : 'STORED' 'AS' FileFormat
- ;
-
-StoredAs_EDIT
- : 'STORED' 'AS' 'CURSOR'
-   {
-     parser.suggestFileFormats();
-   }
- ;
-
-FileFormat
- : 'AVRO'
- | 'INPUTFORMAT' QuotedValue 'OUTPUTFORMAT' QuotedValue
- | 'JSONFILE'
- | 'ORC'
- | 'PARQUET'
- | 'RCFILE'
- | 'SEQUENCEFILE'
- | 'TEXTFILE'
- ;
-
-RowFormatSpec
- : DelimitedRowFormat
- | 'SERDE' QuotedValue
- ;
-
-RowFormatSpec_EDIT
- : DelimitedRowFormat_EDIT
- ;
-
-DelimitedRowFormat
- : 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy OptionalLinesTerminatedBy OptionalNullDefinedAs
-   {
-     if (!$2 && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 5 }, { value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]};
-     } else if ($2 && $2.suggestKeywords && !$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 5).concat([{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }]) };
-     } else if (!$3 && !$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'COLLECTION ITEMS TERMINATED BY', weight: 4 }, { value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$4 && !$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'MAP KEYS TERMINATED BY', weight: 3 }, { value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$5 && !$6) {
-       $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 2 }, { value: 'NULL DEFINED AS', weight: 1 }] };
-     } else if (!$6) {
-       $$ = { suggestKeywords: [{ value: 'NULL DEFINED AS', weight: 1 }] };
-     }
-   }
- ;
-
-DelimitedRowFormat_EDIT
- : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy_EDIT OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy_EDIT
-   OptionalLinesTerminatedBy OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy_EDIT OptionalNullDefinedAs
- | 'DELIMITED' OptionalFieldsTerminatedBy OptionalCollectionItemsTerminatedBy OptionalMapKeysTerminatedBy
-   OptionalLinesTerminatedBy OptionalNullDefinedAs_EDIT
- ;
-
-OptionalFieldsTerminatedBy
- :
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue  -> { suggestKeywords: ['ESCAPED BY'] }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'BY' SingleQuotedValue
- ;
-
-OptionalFieldsTerminatedBy_EDIT
- : 'FIELDS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'FIELDS' 'TERMINATED' 'BY' SingleQuotedValue 'ESCAPED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalCollectionItemsTerminatedBy
- :
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalCollectionItemsTerminatedBy_EDIT
- : 'COLLECTION' 'CURSOR'
-   {
-     parser.suggestKeywords(['ITEMS TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'COLLECTION' 'ITEMS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalMapKeysTerminatedBy
- :
- | 'MAP' 'KEYS' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalMapKeysTerminatedBy_EDIT
- : 'MAP' 'CURSOR'
-   {
-     parser.suggestKeywords(['KEYS TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'MAP' 'KEYS' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalLinesTerminatedBy
- :
- | 'LINES' 'TERMINATED' 'BY' SingleQuotedValue
- ;
-
-OptionalLinesTerminatedBy_EDIT
- : 'LINES' 'CURSOR'
-   {
-     parser.suggestKeywords(['TERMINATED BY']);
-   }
- | 'LINES' 'TERMINATED' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- ;
-
-OptionalNullDefinedAs
- :
- | 'NULL' 'DEFINED' 'AS' SingleQuotedValue
- ;
-
-OptionalNullDefinedAs_EDIT
- : 'NULL' 'CURSOR'
-   {
-     parser.suggestKeywords(['DEFINED AS']);
-   }
- | 'NULL' 'DEFINED' 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- ;
-
-OptionalWithSerdeproperties
- :
- | WithSerdeproperties
- ;
-
-WithSerdeproperties
- :'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-WithSerdeproperties_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList
-   {
-     parser.suggestKeywords(['SERDEPROPERTIES']);
-   }
- ;
-
-OptionalTblproperties
- :
- | TblProperties
- ;
-
-TblProperties
- : 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-OptionalAsSelectStatement
- :
- | 'AS' CommitLocations QuerySpecification
- ;
-
-OptionalAsSelectStatement_EDIT
- : 'AS' CommitLocations 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | 'AS' CommitLocations QuerySpecification_EDIT
- ;
-
-CommitLocations
- : /* empty */
-   {
-     parser.commitLocations();
-   }
- ;
-
-ViewDefinition
- : 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
- ;
-
-ViewDefinition_EDIT
- : 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
-   {
-     if (!$3) {
-       parser.suggestKeywords(['IF NOT EXISTS']);
-     }
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment OptionalTblproperties
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'CURSOR'
-   {
-     var keywords = [{value: 'AS', weight: 1 }];
-     if (!$7) {
-       keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
-       if (!$6) {
-         keywords.push({ value: 'COMMENT', weight: 3 });
-       }
-     }
-     parser.suggestKeywords(keywords);
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification_EDIT
- | 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment OptionalTblproperties 'AS' QuerySpecification
- ;
-
-FunctionDefinition
- : TemporaryFunction
- ;
-
-FunctionDefinition_EDIT
- : TemporaryFunction_EDIT
- ;
-
-FunctionDefinition
- : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing
- ;
-
-FunctionDefinition_EDIT
- : 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing_EDIT
- | 'CREATE' 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalUsing 'CURSOR'
-   {
-     if (!$6) {
-       parser.suggestKeywords(['USING']);
-     } else {
-       parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
-     }
-   }
- ;
-
-TemporaryFunction
- : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'AS' SingleQuotedValue
- ;
-
-TemporaryFunction_EDIT
- : 'CREATE' 'TEMPORARY' 'FUNCTION' RegularIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- ;
-
-FunctionReference
- : SingleQuotedValue
- ;
-
-FunctionReference_EDIT
- : SingleQuotedValue_EDIT
-   {
-     parser.suggestFunctions();
-     parser.suggestAggregateFunctions();
-     parser.suggestAnalyticFunctions();
-   }
- ;
-
-OptionalUsing
- :
- | 'USING' OneOrMoreFunctionResources
- ;
-
-OptionalUsing_EDIT
- : 'USING' 'CURSOR'
-   {
-     parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']);
-   }
- ;
-
-OneOrMoreFunctionResources
- : FunctionResource
- | OneOrMoreFunctionResources ',' FunctionResource
- ;
-
-FunctionResource
- : FunctionResourceType SingleQuotedValue
- ;
-
-FunctionResourceType
- : 'ARCHIVE'
- | 'FILE'
- | 'JAR'
- ;
-
-OptionalParenthesizedViewColumnList
- :
- | ParenthesizedViewColumnList
- ;
-
-ParenthesizedViewColumnList
- : '(' ViewColumnList ')'
- ;
-
-ParenthesizedViewColumnList_EDIT
- : '(' ViewColumnList_EDIT RightParenthesisOrError
-   {
-     if (!$2) {
-       parser.suggestKeywords(['COMMENT']);
-     }
-   }
- ;
-
-ViewColumnList
- : ColumnReference OptionalComment
- | ViewColumnList ',' ColumnReference OptionalComment
- ;
-
-ViewColumnList_EDIT
- : ColumnReference OptionalComment 'CURSOR'                                        -> $2
- | ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList                     -> $2
- | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR'                     -> $4
- | ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList  -> $4
- ;
-
-RoleDefinition
- : 'CREATE' 'ROLE' RegularIdentifier
- ;
-
-IndexDefinition
- : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat
-   OptionalStoredAsOrBy  OptionalHdfsLocation OptionalTblproperties OptionalComment
- ;
-
-IndexDefinition_EDIT
- : 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['ON TABLE']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' 'CURSOR'
-   {
-     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable RowFormat_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat StoredAsOrBy_EDIT OptionalHdfsLocation
-   OptionalTblproperties OptionalComment
-   {
-     if ($13 && parser.yy.result.suggestKeywords && parser.yy.result.suggestKeywords.length === 2) {
-       parser.suggestKeywords(['AS']);
-     }
-   }
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy HdfsLocation_EDIT
-   OptionalTblproperties OptionalComment
- | 'CREATE' 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList
-   'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalRowFormat OptionalStoredAsOrBy OptionalHdfsLocation
-   OptionalTblproperties OptionalComment 'CURSOR'
-   {
-     if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'WITH DEFERRED REBUILD', weight: 7 }, { value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$11 && !$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'IDXPROPERTIES', weight: 6 }, { value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$12 && !$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'IN TABLE', weight: 5 }, { value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$13 && !$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'ROW FORMAT', weight: 4 }, { value: 'STORED AS', weight: 4 }, { value: 'STORED BY', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if ($13 && $13.suggestKeywords && !$14 && !$15 && !$16) {
-       parser.suggestKeywords(parser.createWeightedKeywords($13.suggestKeywords, 5).concat([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]));
-     } else if (!$14 && !$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'STORED AS', weight: 4 }, { value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$15 && !$16 && !$17) {
-       parser.suggestKeywords([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$16 && !$17) {
-       parser.suggestKeywords([{ value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]);
-     } else if (!$17) {
-       parser.suggestKeywords([{ value: 'COMMENT', weight: 1 }]);
-     }
-   }
- ;
-
-ExistingTable
- : SchemaQualifiedTableIdentifier
-   {
-     parser.addTablePrimary($1);
-   }
- ;
-
-ExistingTable_EDIT
- : SchemaQualifiedTableIdentifier_EDIT
- ;
-
-IndexType
- : QuotedValue
- ;
-
-IndexType_EDIT
- : QuotedValue_EDIT
-   {
-     parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']);
-   }
- ;
-
-OptionalWithDeferredRebuild
- :
- | 'WITH' 'DEFERRED' 'REBUILD'
- ;
-
-OptionalWithDeferredRebuild_EDIT
- : 'WITH' 'CURSOR'
-   {
-     parser.suggestKeywords(['DEFERRED REBUILD']);
-   }
- | 'WITH' 'DEFERRED' 'CURSOR'
-   {
-     parser.suggestKeywords(['REBUILD']);
-   }
- ;
-
-OptionalIdxProperties
- :
- | 'IDXPROPERTIES' ParenthesizedPropertyAssignmentList
- ;
-
-OptionalInTable
- :
- | 'IN' 'TABLE' SchemaQualifiedTableIdentifier
- ;
-
-OptionalInTable_EDIT
- : 'IN' 'CURSOR'
-   {
-     parser.suggestKeywords(['TABLE']);
-   }
- | 'IN' 'TABLE' 'CURSOR'
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | 'IN' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
- ;
-
-
-ParenthesizedIndexColumnList
- : '(' IndexColumnList ')'
- ;
-
-ParenthesizedIndexColumnList_EDIT
- : '(' IndexColumnList_EDIT RightParenthesisOrError
-   {
-     parser.suggestColumns();
-   }
- ;
-
-IndexColumnList
- : ColumnReference
- | IndexColumnList ',' ColumnReference
- ;
-
-IndexColumnList_EDIT
- : AnyCursor
- | IndexColumnList ',' AnyCursor
- | AnyCursor ',' IndexColumnList
- | IndexColumnList ',' AnyCursor ',' IndexColumnList
- ;
-
-MacroDefinition
- : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression
- ;
-
-MacroDefinition_EDIT
- : 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT ValueExpression
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments 'CURSOR'
-   {
-     parser.suggestFunctions();
-   }
- | 'CREATE' 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression_EDIT
- ;
-
-MacroArguments
- : '(' ')'
- | '(' MacroArgumentList ')'
- ;
-
-MacroArguments_EDIT
- : '(' MacroArgumentList_EDIT RightParenthesisOrError
- ;
-
-
-MacroArgumentList
- : MacroArgument
- | MacroArgumentList ',' MacroArgument
- ;
-
-MacroArgumentList_EDIT
- : MacroArgument_EDIT
- | MacroArgumentList ',' MacroArgument_EDIT
- | MacroArgument_EDIT ',' MacroArgumentList
- | MacroArgumentList ',' MacroArgument_EDIT ',' MacroArgumentList
- ;
-
-MacroArgument
- : RegularIdentifier ColumnDataType
- ;
-
-MacroArgument_EDIT
- : RegularIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(parser.getColumnDataTypeKeywords());
-   }
- | RegularIdentifier ColumnDataType_EDIT
- ;

+ 22 - 4
desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json

@@ -10,6 +10,17 @@
     "../hive/alter/alter_materialized_view.jison",
     "../hive/alter/alter_table.jison",
     "../hive/alter/alter_view.jison",
+    "../hive/analyze/analyze_table.jison",
+    "create/create_common.jison",
+    "../hive/create/create_database.jison",
+    "create/create_database_no_db.jison",
+    "../hive/create/create_function.jison",
+    "../hive/create/create_index.jison",
+    "../hive/create/create_role.jison",
+    "../hive/create/create_table.jison",
+    "../hive/create/create_temporary_function.jison",
+    "../hive/create/create_temporary_macro.jison",
+    "../hive/create/create_view.jison",
     "../hive/delete/delete.jison",
     "../hive/drop/drop_common.jison",
     "../hive/drop/drop_database.jison",
@@ -66,8 +77,6 @@
     "../hive/udf/sql_extract.jison",
     "../generic/use/use.jison",
     "../generic/sql_valueExpression.jison",
-    "sql_analyze.jison",
-    "sql_create.jison",
     "../hive/sql_error.jison",
     "../hive/sql_grant.jison",
     "../hive/sql_insert.jison",
@@ -88,6 +97,17 @@
     "../hive/alter/alter_materialized_view.jison",
     "../hive/alter/alter_table.jison",
     "../hive/alter/alter_view.jison",
+    "../hive/analyze/analyze_table.jison",
+    "create/create_common.jison",
+    "../hive/create/create_database.jison",
+    "create/create_database_no_db.jison",
+    "../hive/create/create_function.jison",
+    "../hive/create/create_index.jison",
+    "../hive/create/create_role.jison",
+    "../hive/create/create_table.jison",
+    "../hive/create/create_temporary_function.jison",
+    "../hive/create/create_temporary_macro.jison",
+    "../hive/create/create_view.jison",
     "../hive/delete/delete.jison",
     "../hive/drop/drop_common.jison",
     "../hive/drop/drop_database.jison",
@@ -144,8 +164,6 @@
     "../hive/udf/sql_extract.jison",
     "../generic/use/use.jison",
     "../generic/sql_valueExpression.jison",
-    "sql_analyze.jison",
-    "sql_create.jison",
     "../hive/sql_grant.jison",
     "../hive/sql_insert.jison",
     "sql_load.jison",

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است