// 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 | AnyCreate OptionalHiveTemporary OptionalExternal 'CURSOR' { if ($3) { parser.suggestKeywords(['TABLE']); } else if (parser.isHive()) { if ($2) { parser.suggestKeywords(['EXTERNAL TABLE', 'FUNCTION', 'MACRO', 'TABLE']); } else { parser.suggestKeywords(['DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'INDEX', 'ROLE', 'SCHEMA', 'TABLE', 'TEMPORARY EXTERNAL TABLE', 'TEMPORARY FUNCTION', 'TEMPORARY MACRO', 'TEMPORARY TABLE', 'VIEW']); } } else if (parser.isImpala()) { parser.suggestKeywords(['AGGREGATE FUNCTION', 'DATABASE', 'EXTERNAL TABLE', 'FUNCTION', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']); } else { parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']); } } ; DatabaseDefinition : AnyCreate DatabaseOrSchema OptionalIfNotExists | AnyCreate DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals ; DatabaseDefinition_EDIT : AnyCreate DatabaseOrSchema OptionalIfNotExists 'CURSOR' { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate DatabaseOrSchema OptionalIfNotExists_EDIT | AnyCreate DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier | AnyCreate DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR' ; DatabaseDefinitionOptionals : OptionalComment OptionalHdfsLocation OptionalHiveDbProperties { var keywords = []; if (!$3 && parser.isHive()) { 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 OptionalHiveDbProperties | OptionalComment HdfsLocation_EDIT OptionalHiveDbProperties ; OptionalComment : | Comment ; Comment : HiveOrImpalaComment QuotedValue ; Comment_INVALID : HiveOrImpalaComment SINGLE_QUOTE | HiveOrImpalaComment DOUBLE_QUOTE | HiveOrImpalaComment SINGLE_QUOTE VALUE | HiveOrImpalaComment DOUBLE_QUOTE VALUE ; OptionalComment_INVALID : Comment_INVALID ; OptionalHiveDbProperties : | HiveDbProperties ; HiveDbProperties : 'WITH' 'DBPROPERTIES' ParenthesizedPropertyAssignmentList | 'WITH' 'DBPROPERTIES' | 'WITH' 'CURSOR' { parser.suggestKeywords(['DBPROPERTIES']); } ; ParenthesizedPropertyAssignmentList : '(' PropertyAssignmentList ')' ; PropertyAssignmentList : PropertyAssignment | PropertyAssignmentList ',' PropertyAssignment ; PropertyAssignment : QuotedValue '=' UnsignedValueSpecification ; TableDefinition : AnyCreate OptionalHiveTemporary OptionalExternal AnyTable OptionalIfNotExists TableDefinitionRightPart LifeCyclePart ; LifeCyclePart : | 'LIFECYCLE' 'UNSIGNED_INTEGER' ; TableDefinition_EDIT : AnyCreate OptionalHiveTemporary OptionalExternal AnyTable OptionalIfNotExists TableDefinitionRightPart_EDIT | AnyCreate OptionalHiveTemporary OptionalExternal AnyTable OptionalIfNotExists 'CURSOR' { if (!$5) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate OptionalHiveTemporary OptionalExternal AnyTable OptionalIfNotExists_EDIT ; TableDefinitionRightPart : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement ; TableDefinitionRightPart_EDIT : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy SortBy_EDIT OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy ClusteredBy_EDIT OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy SkewedBy_EDIT OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy StoredAsOrBy_EDIT OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy WithSerdeproperties_EDIT OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties HdfsLocation_EDIT OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties CachedIn WithReplication_EDIT OptionalAsSelectStatement | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached OptionalAsSelectStatement_EDIT | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalSortBy OptionalClusteredBy OptionalSkewedBy OptionalStoredAsOrBy OptionalWithSerdeproperties OptionalHdfsLocation OptionalTblproperties OptionalCachedInOrUncached 'CURSOR' { var keywords = []; if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'LIKE', weight: 1 }); if (parser.isImpala()) { keywords.push({ value: 'LIKE PARQUET', weight: 1 }); } } else { if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'COMMENT', weight: 11 }); } if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'PARTITIONED BY', weight: 10 }); if (parser.isImpala()) { keywords.push({ value: 'PARTITION BY', weight: 10 }); } } if (parser.isImpala() && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'SORT BY', weight: 9 }); } if (parser.isHive() && !$5 && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'CLUSTERED BY', weight: 8 }); } if (parser.isHive() && !$6 && !$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'SKEWED BY', weight: 7 }); } else if (parser.isHive() && $6 && $6.suggestKeywords && !$7 && !$8 && !$9 && !$10 && !$10) { keywords = keywords.concat(parser.createWeightedKeywords($6.suggestKeywords, 7)); // Get the last optional from SKEWED BY } if (!$7 && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'ROW FORMAT', weight: 6 }); keywords.push({ value: 'STORED AS', weight: 6 }); if (parser.isHive()) { keywords.push({ value: 'STORED BY', weight: 6 }); } } else if ($7 && $7.suggestKeywords && !$8 && !$9 && !$10 && !$11) { keywords = keywords.concat(parser.createWeightedKeywords($7.suggestKeywords, 6)); } if ((($7 && $7.storedBy) || parser.isImpala()) && !$8 && !$9 && !$10 && !$11) { keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 5 }); } if (!$9 && !$10 && !$11) { keywords.push({ value: 'LOCATION', weight: 4 }); } if (!$10 && !$11) { keywords.push({ value: 'TBLPROPERTIES', weight: 3 }); } if (parser.isImpala() && !$11) { keywords.push({ value: 'CACHED IN', weight: 2 }, { value: 'UNCACHED', weight: 2 }); } if (parser.isImpala() && $11 && $11.suggestKeywords) { keywords = keywords.concat(parser.createWeightedKeywords($11.suggestKeywords, 2)); } keywords.push({ value: 'AS', weight: 1 }); } if (keywords.length > 0) { parser.suggestKeywords(keywords); } } ; TableIdentifierAndOptionalColumnSpecification : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike -> $2 ; TableIdentifierAndOptionalColumnSpecification_EDIT : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT | SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike ; OptionalColumnSpecificationsOrLike : | ParenthesizedColumnSpecificationList | 'LIKE_PARQUET' HdfsPath | 'LIKE' SchemaQualifiedTableIdentifier ; OptionalColumnSpecificationsOrLike_EDIT : ParenthesizedColumnSpecificationList_EDIT | 'LIKE_PARQUET' HdfsPath_EDIT | 'LIKE' 'CURSOR' { parser.suggestTables(); parser.suggestDatabases({ appendDot: true }); if (parser.isImpala()) { parser.suggestKeywords(['PARQUET']); } } | 'LIKE' SchemaQualifiedTableIdentifier_EDIT ; ParenthesizedColumnSpecificationList : '(' ColumnSpecificationList ')' | '(' ColumnSpecificationList ',' ConstraintSpecification ')' ; ParenthesizedColumnSpecificationList_EDIT : '(' ColumnSpecificationList_EDIT RightParenthesisOrError | '(' ColumnSpecificationList ',' ConstraintSpecification_EDIT RightParenthesisOrError | '(' ColumnSpecificationList ',' 'CURSOR' RightParenthesisOrError { if (parser.isImpala()) { parser.suggestKeywords(['PRIMARY KEY']); } else if (parser.isHive()) { parser.suggestKeywords([{ value: 'PRIMARY KEY', weight: 2 }, { value: 'CONSTRAINT', weight: 1 }]); } } ; ColumnSpecificationList : ColumnSpecification | ColumnSpecificationList ',' ColumnSpecification -> $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; var keywords = []; if (parser.isImpala()) { if (!$3['primary']) { keywords.push('PRIMARY KEY'); } if (!$3['encoding']) { keywords.push('ENCODING'); } if (!$3['compression']) { keywords.push('COMPRESSION'); } if (!$3['default']) { keywords.push('DEFAULT'); } if (!$3['block_size']) { keywords.push('BLOCK_SIZE'); } if (!$3['null']) { keywords.push('NOT NULL'); keywords.push('NULL'); } } if (!$3['comment']) { keywords.push('COMMENT'); if (parser.isHive() && $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 | ColumnIdentifier ColumnDataType ColumnOptions_EDIT ; OptionalColumnOptions : -> {} | ColumnOptions ; ColumnOptions : ColumnOption { $$ = {}; $$[$1] = true; } | ColumnOptions ColumnOption { $1[$2] = true; } ; ColumnOptions_EDIT : ColumnOption_EDIT | ColumnOption_EDIT ColumnOptions | ColumnOptions ColumnOption_EDIT | ColumnOptions ColumnOption_EDIT ColumnOptions ; ColumnOption : ImpalaPrimaryKey -> 'primary' | 'ENCODING' RegularIdentifier -> 'encoding' | 'COMPRESSION' RegularIdentifier -> 'compression' | 'DEFAULT' NonParenthesizedValueExpressionPrimary -> 'default' | 'BLOCK_SIZE' UnsignedNumericLiteral -> 'block_size' | 'NOT' 'NULL' -> 'null' | 'NULL' -> 'null' | Comment -> 'comment' ; ColumnOption_EDIT : ImpalaPrimaryKey_EDIT | 'NOT' 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['NULL']); } } ; 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 : ImpalaPrimaryKeySpecification | HivePrimaryKeySpecification | 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification | HivePrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification ; ConstraintSpecification_EDIT : ImpalaPrimaryKeySpecification_EDIT | HivePrimaryKeySpecification_EDIT | HivePrimaryKeySpecification ',' 'CURSOR' { parser.suggestKeywords(['CONSTRAINT']); } | HivePrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR' { parser.suggestKeywords(['FOREIGN KEY']); } | HivePrimaryKeySpecification ',' 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification_EDIT | HivePrimaryKeySpecification_EDIT ',' 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification | 'CONSTRAINT' RegularOrBacktickedIdentifier 'CURSOR' { parser.suggestKeywords(['FOREIGN KEY']); } | 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification_EDIT | 'CURSOR' 'CONSTRAINT' RegularOrBacktickedIdentifier HiveForeignKeySpecification { parser.suggestKeywords(['PRIMARY KEY']); } ; HivePrimaryKeySpecification : HivePrimaryKey ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' ; HivePrimaryKeySpecification_EDIT : HivePrimaryKey_EDIT | HivePrimaryKey ParenthesizedColumnList_EDIT | HivePrimaryKey ParenthesizedColumnList 'CURSOR' { parser.suggestKeywords(['DISABLE NOVALIDATE']); } | HivePrimaryKey ParenthesizedColumnList 'DISABLE' 'CURSOR' { parser.suggestKeywords(['NOVALIDATE']); } | HivePrimaryKey ParenthesizedColumnList_EDIT 'DISABLE' 'NOVALIDATE' ; HiveForeignKeySpecification : 'FOREIGN' 'KEY' ParenthesizedColumnList 'REFERENCES' SchemaQualifiedTableIdentifier ParenthesizedColumnList 'DISABLE' 'NOVALIDATE' OptionalRelyNoRely { parser.addTablePrimary($5); } ; HiveForeignKeySpecification_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' ; ImpalaPrimaryKeySpecification : ImpalaPrimaryKey ParenthesizedColumnList ; ImpalaPrimaryKeySpecification_EDIT : ImpalaPrimaryKey_EDIT | ImpalaPrimaryKey_EDIT ParenthesizedColumnList | ImpalaPrimaryKey ParenthesizedColumnList_EDIT ; ImpalaPrimaryKey : 'PRIMARY' 'KEY' ; ImpalaPrimaryKey_EDIT : 'PRIMARY' 'CURSOR' { parser.suggestKeywords(['KEY']); } ; HivePrimaryKey : 'PRIMARY' 'KEY' ; HivePrimaryKey_EDIT : 'PRIMARY' 'CURSOR' { parser.suggestKeywords(['KEY']); } ; OptionalPartitionedBy : | PartitionedBy ; PartitionedBy : HiveOrImpalaPartitioned 'BY' ParenthesizedColumnSpecificationList | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList | 'PARTITION' 'BY' 'HASH' ParenthesizedColumnList 'PARTITIONS' UnsignedNumericLiteral ; PartitionedBy_EDIT : HiveOrImpalaPartitioned 'CURSOR' { parser.suggestKeywords(['BY']); } | HiveOrImpalaPartitioned 'CURSOR' ParenthesizedColumnSpecificationList { parser.suggestKeywords(['BY']); } | HiveOrImpalaPartitioned 'BY' ParenthesizedColumnSpecificationList_EDIT | HiveOrImpalaPartitioned ParenthesizedColumnSpecificationList_EDIT | 'PARTITION' 'CURSOR' { parser.suggestKeywords(['BY']); } | 'PARTITION' 'BY' 'CURSOR' { parser.suggestKeywords(['HASH', 'RANGE']); } | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList_EDIT | 'PARTITION' 'BY' AnyRange ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT | 'PARTITION' 'BY' 'HASH' ParenthesizedColumnList_EDIT | 'PARTITION' 'BY' 'HASH' ParenthesizedColumnList 'CURSOR' { parser.suggestKeywords(['PARTITIONS']); } | 'PARTITION' 'BY' 'HASH' ParenthesizedColumnList_EDIT 'PARTITIONS' UnsignedNumericLiteral ; OptionalSortBy : | SortBy ; SortBy : 'SORT' 'BY' ParenthesizedColumnList ; SortBy_EDIT : 'SORT' 'CURSOR' { parser.suggestKeywords(['BY']); } | 'SORT' 'BY' ParenthesizedColumnList_EDIT ; ParenthesizedPartitionValuesList : '(' PartitionValueList ')' ; ParenthesizedPartitionValuesList_EDIT : '(' 'CURSOR' RightParenthesisOrError { if (parser.isImpala()) { parser.suggestKeywords(['PARTITION']); } } |'(' PartitionValueList_EDIT RightParenthesisOrError ; PartitionValueList : PartitionValue | PartitionValueList ',' PartitionValue ; PartitionValueList_EDIT : PartitionValue_EDIT | PartitionValueList ',' 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['PARTITION']); } } | PartitionValueList ',' 'CURSOR' ',' PartitionValueList { if (parser.isImpala()) { parser.suggestKeywords(['PARTITION']); } } | PartitionValueList ',' PartitionValue_EDIT | PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList ; PartitionValue : 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression | 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression | 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' | 'PARTITION_VALUE' '=' ValueExpression ; PartitionValue_EDIT : 'PARTITION' 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['VALUE', 'VALUES']); } } | 'PARTITION_VALUE' 'CURSOR' { parser.suggestKeywords(['=']); } | 'PARTITION_VALUE' '=' 'CURSOR' { parser.suggestFunctions(); } | 'PARTITION' ValueExpression_EDIT { if ($2.endsWithLessThanOrEqual && parser.isImpala()) { parser.suggestKeywords(['VALUES']); } } | 'PARTITION' ValueExpression 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['<', '<=']); } } | 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['VALUES']); } } | 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES' | 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['<', '<=']); } } | 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR' { if (parser.isImpala()) { parser.suggestFunctions(); } } | 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT | 'PARTITION' 'VALUES' 'CURSOR' { if (parser.isImpala()) { parser.suggestKeywords(['<', '<=']); } } | 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR' { if (parser.isImpala()) { parser.suggestFunctions(); } } | 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT ; LessThanOrEqualTo : '<' | 'COMPARISON_OPERATOR' // This is fine for autocompletion ; OptionalClusteredBy : | ClusteredBy ; ClusteredBy : 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS' ; ClusteredBy_EDIT : 'CLUSTERED' 'CURSOR' { parser.suggestKeywords(['BY']); } | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalHiveSortedBy | 'CLUSTERED' 'BY' ParenthesizedColumnList_EDIT OptionalHiveSortedBy 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS' | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy 'CURSOR' { if (!$4) { parser.suggestKeywords([{ value: 'INTO', weight: 1 }, { value: 'SORTED BY', weight: 2 }]); } else { parser.suggestKeywords(['INTO']); } } | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy 'INTO' 'UNSIGNED_INTEGER' 'CURSOR' { parser.suggestKeywords(['BUCKETS']); } | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy_EDIT 'INTO' 'UNSIGNED_INTEGER' 'BUCKETS' | 'CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy_EDIT ; OptionalHiveSortedBy : | 'SORTED' 'BY' ParenthesizedSortList ; OptionalHiveSortedBy_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 OptionalHiveStoredAsOrBy ; SkewedBy_EDIT : 'SKEWED' 'CURSOR' { parser.suggestKeywords(['BY']); } | 'SKEWED' 'BY' ParenthesizedColumnList 'CURSOR' { parser.suggestKeywords(['ON']); } ; ParenthesizedSkewedValueList : '(' SkewedValueList ')' ; SkewedValueList : ParenthesizedSimpleValueList | SkewedValueList ',' ParenthesizedSimpleValueList ; OptionalStoredAsOrBy : | StoredAsOrBy ; StoredAsOrBy : StoredAs | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat OptionalWithSerdeproperties OptionalStoredAs { $$ = parser.mergeSuggestKeywords($3, $4) } | 'STORED' 'BY' QuotedValue { $$ = { storedBy: true } } ; StoredAsOrBy_EDIT : HiveOrImpalaStored 'CURSOR' { if (parser.isHive()) { parser.suggestKeywords(['AS', 'BY']); } else { parser.suggestKeywords(['AS']); } } | StoredAs_EDIT | 'ROW' 'CURSOR' { parser.suggestKeywords(['FORMAT']); } | 'ROW' HiveOrImpalaFormat 'CURSOR' { if (parser.isHive()) { parser.suggestKeywords(['DELIMITED', 'SERDE']); } else { parser.suggestKeywords(['DELIMITED']); } } | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat_EDIT | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat HiveOrImpalaStored 'CURSOR' { parser.suggestKeywords(['AS']); } | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat StoredAs_EDIT ; OptionalStoredAs : -> { suggestKeywords: ['STORED AS'] } | StoredAs ; StoredAs : HiveOrImpalaStored AnyAs FileFormat ; StoredAs_EDIT : HiveOrImpalaStored AnyAs 'CURSOR' { parser.suggestFileFormats(); } ; FileFormat : 'AVRO' | 'INPUTFORMAT' QuotedValue 'OUTPUTFORMAT' QuotedValue | 'ORC' | 'PARQUET' | 'RCFILE' | 'SEQUENCEFILE' | 'TEXTFILE' | 'AVRO' | 'KUDU' | 'ORC' | 'PARQUET' | 'RCFILE' | 'SEQUENCEFILE' | 'TEXTFILE' ; HiveOrImpalaRowFormat : HiveRowFormat | ImpalaRowFormat ; HiveOrImpalaRowFormat_EDIT : ImpalaRowFormat_EDIT | HiveRowFormat_EDIT ; HiveRowFormat : HiveDelimitedRowFormat | 'SERDE' QuotedValue ; HiveRowFormat_EDIT : HiveDelimitedRowFormat_EDIT ; HiveDelimitedRowFormat : '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 }] }; } } ; HiveDelimitedRowFormat_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 ; ImpalaRowFormat : 'DELIMITED' OptionalFieldsTerminatedBy OptionalLinesTerminatedBy { if (!$2 && !$3) { $$ = { suggestKeywords: [{ value: 'FIELDS TERMINATED BY', weight: 2 }, { value: 'LINES TERMINATED BY', weight: 1 }] }; } else if ($2 && $2.suggestKeywords && !$3) { $$ = { suggestKeywords: parser.createWeightedKeywords($2.suggestKeywords, 2).concat(['LINES TERMINATED BY']) }; } else if (!$3) { $$ = { suggestKeywords: [{ value: 'LINES TERMINATED BY', weight: 1 }] }; } } ; ImpalaRowFormat_EDIT : 'DELIMITED' OptionalFieldsTerminatedBy_EDIT OptionalLinesTerminatedBy | 'DELIMITED' OptionalFieldsTerminatedBy OptionalLinesTerminatedBy_EDIT ; OptionalFieldsTerminatedBy : | HiveOrImpalaFields HiveOrImpalaTerminated 'BY' SingleQuotedValue -> { suggestKeywords: ['ESCAPED BY'] } | HiveOrImpalaFields HiveOrImpalaTerminated 'BY' SingleQuotedValue HiveOrImpalaEscaped 'BY' SingleQuotedValue ; OptionalFieldsTerminatedBy_EDIT : HiveOrImpalaFields 'CURSOR' { parser.suggestKeywords(['TERMINATED BY']); } | HiveOrImpalaFields HiveOrImpalaTerminated 'CURSOR' { parser.suggestKeywords(['BY']); } | HiveOrImpalaFields HiveOrImpalaTerminated '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 : | HiveOrImpalaLines HiveOrImpalaTerminated 'BY' SingleQuotedValue ; OptionalLinesTerminatedBy_EDIT : HiveOrImpalaLines 'CURSOR' { parser.suggestKeywords(['TERMINATED BY']); } | HiveOrImpalaLines HiveOrImpalaTerminated '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 | 'WITH' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList ; WithSerdeproperties_EDIT : 'WITH' 'CURSOR' { parser.suggestKeywords(['SERDEPROPERTIES']); } | 'WITH' 'CURSOR' ParenthesizedPropertyAssignmentList { parser.suggestKeywords(['SERDEPROPERTIES']); } ; OptionalTblproperties : | TblProperties ; TblProperties : HiveOrImpalaTblproperties ParenthesizedPropertyAssignmentList ; OptionalHiveTblproperties : | 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList ; OptionalAsSelectStatement : | AnyAs CommitLocations QuerySpecification ; OptionalAsSelectStatement_EDIT : AnyAs CommitLocations 'CURSOR' { parser.suggestKeywords(['SELECT']); } | AnyAs CommitLocations QuerySpecification_EDIT ; CommitLocations : /* empty */ { parser.commitLocations(); } ; ViewDefinition : AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification ; ViewDefinition_EDIT : AnyCreate AnyView OptionalIfNotExists 'CURSOR' { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } parser.suggestDatabases({ appendDot: true }); } | AnyCreate AnyView OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate AnyView OptionalIfNotExists_EDIT | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment OptionalHiveTblproperties | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties 'CURSOR' { var keywords = [{value: 'AS', weight: 1 }]; if (!$7) { if (parser.isHive()) { keywords.push({ value: 'TBLPROPERTIES', weight: 2 }); } if (!$6) { keywords.push({ value: 'COMMENT', weight: 3 }); } } parser.suggestKeywords(keywords); } | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs 'CURSOR' { parser.suggestKeywords(['SELECT']); } | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification_EDIT | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification ; FunctionDefinition : ImpalaFunctionDefinition | ImpalaAggregateFunctionDefinition | HiveFunctionDefinition | HiveTemporaryFunction ; FunctionDefinition_EDIT : ImpalaFunctionDefinition_EDIT | ImpalaAggregateFunctionDefinition_EDIT | HiveFunctionDefinition_EDIT | HiveTemporaryFunction_EDIT ; ImpalaFunctionDefinition : AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol ; ImpalaFunctionDefinition_EDIT : AnyCreate 'FUNCTION' OptionalIfNotExists 'CURSOR' { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } parser.suggestDatabases({ appendDot: true }); } | AnyCreate 'FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol { if (!$3) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList 'CURSOR' { parser.suggestKeywords(['RETURNS']); } | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns 'CURSOR' { parser.suggestKeywords(['LOCATION']); } | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation 'CURSOR' { parser.suggestKeywords(['SYMBOL']); } | AnyCreate 'FUNCTION' OptionalIfNotExists_EDIT | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT | AnyCreate 'FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns HdfsLocation ImpalaSymbol | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT HdfsLocation ImpalaSymbol | AnyCreate 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT ImpalaSymbol ; ImpalaAggregateFunctionDefinition : AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate ; ImpalaAggregateFunctionDefinition_EDIT : AnyCreate 'AGGREGATE' 'CURSOR' { parser.suggestKeywords(['FUNCTION']); } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate { if (!$4) { parser.suggestKeywords(['IF NOT EXISTS']); } } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists 'CURSOR' { if (!$4) { parser.suggestKeywords(['IF NOT EXISTS']); } parser.suggestDatabases({ appendDot: true }); } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList 'CURSOR' { parser.suggestKeywords(['RETURNS']); } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns 'CURSOR' { parser.suggestKeywords(['LOCATION']); } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn 'CURSOR' { if (!$9) { parser.suggestKeywords([{value: 'INIT_FN', weight: 2 }, {value: 'UPDATE_FN', weight: 1 }]); } else { parser.suggestKeywords([{value: 'UPDATE_FN', weight: 1 }]); } } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn 'CURSOR' { parser.suggestKeywords(['MERGE_FN']); } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate 'CURSOR' { if (!$12 && !$13 && !$14 && !$15 && !$16) { parser.suggestKeywords([{value: 'PREPARE_FN', weight: 5 }, {value: 'CLOSE_FN', weight: 4 }, {value: 'SERIALIZE_FN', weight: 3 }, {value: 'FINALIZE_FN', weight: 2 }, {value: 'INTERMEDIATE', weight: 1 }]); } else if ($12 && !$13 && !$14 && !$15 && !$16) { parser.suggestKeywords([{value: 'CLOSE_FN', weight: 4 }, {value: 'SERIALIZE_FN', weight: 3 }, {value: 'FINALIZE_FN', weight: 2 }, {value: 'INTERMEDIATE', weight: 1 }]); } else if ($13 && !$14 && !$15 && !$16) { parser.suggestKeywords([{value: 'SERIALIZE_FN', weight: 3 }, {value: 'FINALIZE_FN', weight: 2 }, {value: 'INTERMEDIATE', weight: 1 }]); } else if ($14 && !$15 && !$16) { parser.suggestKeywords([{value: 'FINALIZE_FN', weight: 2 }, {value: 'INTERMEDIATE', weight: 1 }]); } else if ($15 && !$16) { parser.suggestKeywords([{value: 'INTERMEDIATE', weight: 1 }]); } } | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT OptionalImpalaInitFn | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn_EDIT OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn_EDIT OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn_EDIT OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn_EDIT OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn_EDIT OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn Intermediate_EDIT | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn_EDIT ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate | AnyCreate 'AGGREGATE' 'FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn_EDIT ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn OptionalIntermediate ; HiveFunctionDefinition : AnyCreate 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalHiveUsing ; HiveFunctionDefinition_EDIT : AnyCreate 'FUNCTION' SchemaQualifiedIdentifier 'CURSOR' { parser.suggestKeywords(['AS']); } | AnyCreate 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalHiveUsing_EDIT | AnyCreate 'FUNCTION' SchemaQualifiedIdentifier 'AS' SingleQuotedValue OptionalHiveUsing 'CURSOR' { if (!$6) { parser.suggestKeywords(['USING']); } else { parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']); } } ; HiveTemporaryFunction : AnyCreate 'TEMPORARY' 'FUNCTION' RegularIdentifier 'AS' SingleQuotedValue ; HiveTemporaryFunction_EDIT : AnyCreate 'TEMPORARY' 'FUNCTION' RegularIdentifier 'CURSOR' { parser.suggestKeywords(['AS']); } ; ParenthesizedImpalaArgumentList : '(' ')' | '(' ImpalaArgumentList OptionalVariableArguments')' ; ParenthesizedImpalaArgumentList_EDIT : '(' ImpalaArgumentList_EDIT RightParenthesisOrError { parser.suggestKeywords(parser.getTypeKeywords()); } | '(' ImpalaArgumentList 'CURSOR' RightParenthesisOrError { parser.suggestKeywords(['...']); } ; ImpalaArgumentList : PrimitiveType | ImpalaArgumentList ',' PrimitiveType ; ImpalaArgumentList_EDIT : AnyCursor | ImpalaArgumentList ',' AnyCursor | AnyCursor ',' ImpalaArgumentList | ImpalaArgumentList ',' AnyCursor ',' ImpalaArgumentList ; OptionalVariableArguments : | '...' ; ImpalaReturns : 'RETURNS' PrimitiveType ; ImpalaReturns_EDIT : 'RETURNS' 'CURSOR' { parser.suggestKeywords(parser.getTypeKeywords()); } ; ImpalaSymbol : 'SYMBOL' '=' SingleQuotedValue ; OptionalImpalaInitFn : | 'INIT_FN' '=' FunctionReference ; OptionalImpalaInitFn_EDIT : 'INIT_FN' '=' FunctionReference_EDIT ; ImpalaUpdateFn : 'UPDATE_FN' '=' FunctionReference ; ImpalaUpdateFn_EDIT : 'UPDATE_FN' '=' FunctionReference_EDIT ; ImpalaMergeFn : 'MERGE_FN' '=' FunctionReference ; ImpalaMergeFn_EDIT : 'MERGE_FN' '=' FunctionReference_EDIT ; OptionalImpalaPrepareFn : | 'PREPARE_FN' '=' FunctionReference ; OptionalImpalaPrepareFn_EDIT : 'PREPARE_FN' '=' FunctionReference_EDIT ; OptionalImpalaCloseFn : | 'CLOSE_FN' '=' FunctionReference ; OptionalImpalaCloseFn_EDIT : 'CLOSE_FN' '=' FunctionReference_EDIT ; OptionalImpalaSerializeFn : | 'SERIALIZE_FN' '=' FunctionReference ; OptionalImpalaSerializeFn_EDIT : 'SERIALIZE_FN' '=' FunctionReference_EDIT ; OptionalImpalaFinalizeFn : | 'FINALIZE_FN' '=' FunctionReference ; OptionalImpalaFinalizeFn_EDIT : 'FINALIZE_FN' '=' FunctionReference_EDIT ; OptionalIntermediate : | 'INTERMEDIATE' PrimitiveType ; Intermediate_EDIT : 'INTERMEDIATE' 'CURSOR' { parser.suggestKeywords(parser.getTypeKeywords()); } ; FunctionReference : SingleQuotedValue ; FunctionReference_EDIT : SingleQuotedValue_EDIT { parser.suggestFunctions(); parser.suggestAggregateFunctions(); parser.suggestAnalyticFunctions(); } ; OptionalHiveUsing : | 'USING' OneOrMoreFunctionResources ; OptionalHiveUsing_EDIT : 'USING' 'CURSOR' { parser.suggestKeywords(['ARCHIVE', 'FILE', 'JAR']); } ; OneOrMoreFunctionResources : FunctionResource | OneOrMoreFunctionResources ',' FunctionResource ; FunctionResource : FunctionResourceType SingleQuotedValue ; FunctionResourceType : 'ARCHIVE' | 'FILE' | 'JAR' ; AnyView : 'VIEW' | 'VIEW' ; 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 : AnyCreate AnyRole RegularIdentifier ; AnyRole : 'ROLE' | 'ROLE' | 'ROLE' ; IndexDefinition : AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment ; ExistingTable : SchemaQualifiedTableIdentifier { parser.addTablePrimary($1); } ; ExistingTable_EDIT : SchemaQualifiedTableIdentifier_EDIT ; IndexDefinition_EDIT : AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'CURSOR' { parser.suggestKeywords(['ON TABLE']); } | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'CURSOR' { parser.suggestKeywords(['TABLE']); } | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' 'CURSOR' { parser.suggestTables(); parser.suggestDatabases({ appendDot: true }); } | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'CURSOR' { parser.suggestKeywords(['AS']); } | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' 'CURSOR' { parser.suggestKeywords(['\'BITMAP\'', '\'COMPACT\'']); } | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType_EDIT OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable_EDIT ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList_EDIT 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild_EDIT OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable StoredAsOrBy_EDIT OptionalHdfsLocation OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalComment | AnyCreate 'INDEX' RegularOrBacktickedIdentifier 'ON' 'TABLE' ExistingTable ParenthesizedIndexColumnList 'AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalComment 'CURSOR' { if (!$10 && !$11 && !$12 && !$13 && !$14 && !$15 && !$16) { 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) { 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) { 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) { 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, 4).concat([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }])); } else if (!$14 && !$15 && !$16) { parser.suggestKeywords([{ value: 'LOCATION', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]); } else if (!$15 && !$16) { parser.suggestKeywords([{ value: 'TBLPROPERTIES', weight: 2 }, { value: 'COMMENT', weight: 1 }]); } else if (!$16) { parser.suggestKeywords([{ value: 'COMMENT', weight: 1 }]); } } ; 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 : AnyCreate 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments ValueExpression ; MacroDefinition_EDIT : AnyCreate 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT | AnyCreate 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments_EDIT ValueExpression | AnyCreate 'TEMPORARY' 'MACRO' RegularIdentifier MacroArguments 'CURSOR' { parser.suggestFunctions(); } | AnyCreate '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 ;