Feat column codeCompletion (#218)
* feat: flink support column suggestion * feat: flink column suggestion unit test * feat: hive support column suggestion * feat: hive column suggestion unit test * feat: trinosql support column suggestion * feat: trino column suggest unit test * feat: sparksql collect column suggesstion * feat: spark column suggestion unit test * feat: rebuild flinksql lib
This commit is contained in:
@ -139,9 +139,13 @@ columnOptionDefinition
|
||||
;
|
||||
|
||||
physicalColumnDefinition
|
||||
: columnName columnType columnConstraint? commentSpec?
|
||||
: columnNameCreate columnType columnConstraint? commentSpec?
|
||||
;
|
||||
|
||||
columnNameCreate
|
||||
: uid
|
||||
| expression;
|
||||
|
||||
columnName
|
||||
: uid | expression
|
||||
;
|
||||
@ -197,7 +201,7 @@ commentSpec
|
||||
;
|
||||
|
||||
metadataColumnDefinition
|
||||
: columnName columnType KW_METADATA (KW_FROM metadataKey)? KW_VIRTUAL?
|
||||
: columnNameCreate columnType KW_METADATA (KW_FROM metadataKey)? KW_VIRTUAL?
|
||||
;
|
||||
|
||||
metadataKey
|
||||
@ -205,7 +209,7 @@ metadataKey
|
||||
;
|
||||
|
||||
computedColumnDefinition
|
||||
: columnName KW_AS computedColumnExpression commentSpec?
|
||||
: columnNameCreate KW_AS computedColumnExpression commentSpec?
|
||||
;
|
||||
|
||||
// 计算表达式
|
||||
@ -214,7 +218,7 @@ computedColumnExpression
|
||||
;
|
||||
|
||||
watermarkDefinition
|
||||
: KW_WATERMARK KW_FOR expression KW_AS expression
|
||||
: KW_WATERMARK KW_FOR columnName KW_AS expression
|
||||
;
|
||||
|
||||
tableConstraint
|
||||
@ -238,9 +242,9 @@ transformList
|
||||
;
|
||||
|
||||
transform
|
||||
: qualifiedName #identityTransform
|
||||
| transformName=identifier
|
||||
LR_BRACKET transformArgument (COMMA transformArgument)* RR_BRACKET #applyTransform
|
||||
: columnName #identityTransform
|
||||
| qualifiedName #columnTransform
|
||||
| LR_BRACKET transformArgument (COMMA transformArgument)* RR_BRACKET #applyTransform
|
||||
;
|
||||
|
||||
transformArgument
|
||||
@ -424,7 +428,7 @@ selectClause
|
||||
|
||||
projectItemDefinition
|
||||
: overWindowItem
|
||||
| expression (KW_AS? expression)?
|
||||
| columnName (KW_AS? expression )?
|
||||
;
|
||||
|
||||
overWindowItem
|
||||
@ -501,12 +505,12 @@ timeIntervalParamName
|
||||
;
|
||||
|
||||
columnDescriptor
|
||||
: KW_DESCRIPTOR LR_BRACKET uid RR_BRACKET
|
||||
: KW_DESCRIPTOR LR_BRACKET columnName RR_BRACKET
|
||||
;
|
||||
|
||||
joinCondition
|
||||
: KW_ON booleanExpression
|
||||
| KW_USING LR_BRACKET uid (COMMA uid)* RR_BRACKET
|
||||
| KW_USING columnNameList
|
||||
;
|
||||
|
||||
whereClause
|
||||
@ -518,7 +522,7 @@ groupByClause
|
||||
;
|
||||
|
||||
groupItemDefinition
|
||||
: expression
|
||||
: columnName
|
||||
| groupWindowFunction
|
||||
| LR_BRACKET RR_BRACKET
|
||||
| LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||
@ -588,7 +592,7 @@ orderByCaluse
|
||||
;
|
||||
|
||||
orderItemDefition
|
||||
: expression ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
|
||||
: columnName ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
|
||||
;
|
||||
|
||||
limitClause
|
||||
@ -596,7 +600,7 @@ limitClause
|
||||
;
|
||||
|
||||
partitionByClause
|
||||
: KW_PARTITION KW_BY expression (COMMA expression)*
|
||||
: KW_PARTITION KW_BY columnName (COMMA columnName)*
|
||||
;
|
||||
|
||||
quantifiers
|
||||
|
@ -814,11 +814,15 @@ columnNameList
|
||||
;
|
||||
|
||||
columnName
|
||||
: id_ (DOT id_)*
|
||||
;
|
||||
|
||||
columnNameCreate
|
||||
: id_
|
||||
;
|
||||
|
||||
extColumnName
|
||||
: id_ (DOT (KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | id_))*
|
||||
: columnName (DOT (KW_ELEM_TYPE | KW_KEY_TYPE | KW_VALUE_TYPE | id_))*
|
||||
;
|
||||
|
||||
columnNameOrderList
|
||||
@ -921,7 +925,7 @@ nullOrdering
|
||||
;
|
||||
|
||||
columnNameOrder
|
||||
: id_ orderSpec=orderSpecification? nullSpec=nullOrdering?
|
||||
: columnName orderSpec=orderSpecification? nullSpec=nullOrdering?
|
||||
;
|
||||
|
||||
columnNameCommentList
|
||||
@ -929,7 +933,7 @@ columnNameCommentList
|
||||
;
|
||||
|
||||
columnNameComment
|
||||
: colName=id_ (KW_COMMENT comment=StringLiteral)?
|
||||
: colName=columnNameCreate (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
orderSpecificationRewrite
|
||||
@ -938,11 +942,11 @@ orderSpecificationRewrite
|
||||
;
|
||||
|
||||
columnRefOrder
|
||||
: expression orderSpec=orderSpecificationRewrite? nullSpec=nullOrdering?
|
||||
: (columnName | expression) orderSpec=orderSpecificationRewrite? nullSpec=nullOrdering?
|
||||
;
|
||||
|
||||
columnNameType
|
||||
: colName=id_ colType (KW_COMMENT comment=StringLiteral)?
|
||||
: colName=columnNameCreate colType (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
columnNameTypeOrConstraint
|
||||
@ -956,7 +960,7 @@ tableConstraint
|
||||
;
|
||||
|
||||
columnNameTypeConstraint
|
||||
: colName=id_ colType columnConstraint? (KW_COMMENT comment=StringLiteral)?
|
||||
: colName=columnNameCreate colType columnConstraint? (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
columnConstraint
|
||||
@ -1012,7 +1016,7 @@ constraintOptsAlter
|
||||
;
|
||||
|
||||
columnNameColonType
|
||||
: colName=id_ COLON colType (KW_COMMENT comment=StringLiteral)?
|
||||
: colName=columnNameCreate COLON colType (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
colType
|
||||
@ -1198,7 +1202,7 @@ deleteStatement
|
||||
|
||||
/*SET <columName> = (3 + col2)*/
|
||||
columnAssignmentClause
|
||||
: tableOrColumn EQUAL precedencePlusExpressionOrDefault
|
||||
: columnName EQUAL precedencePlusExpressionOrDefault
|
||||
;
|
||||
|
||||
precedencePlusExpressionOrDefault
|
||||
@ -1461,12 +1465,12 @@ alterStatementSuffixDropConstraint
|
||||
;
|
||||
|
||||
alterStatementSuffixRenameCol
|
||||
: KW_CHANGE KW_COLUMN? oldName=id_ newName=id_ colType alterColumnConstraint?
|
||||
: KW_CHANGE KW_COLUMN? oldName=columnName newName=columnNameCreate colType alterColumnConstraint?
|
||||
(KW_COMMENT comment=StringLiteral)? alterStatementChangeColPosition? restrictOrCascade?
|
||||
;
|
||||
|
||||
alterStatementSuffixUpdateStatsCol
|
||||
: KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=id_ KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
|
||||
: KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=columnName KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
alterStatementSuffixUpdateStats
|
||||
@ -1574,7 +1578,7 @@ alterStatementSuffixRenamePart
|
||||
;
|
||||
|
||||
alterStatementSuffixStatsPart
|
||||
: KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=id_ KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
|
||||
: KW_UPDATE KW_STATISTICS KW_FOR KW_COLUMN? colName=columnName KW_SET tableProperties (KW_COMMENT comment=StringLiteral)?
|
||||
;
|
||||
|
||||
alterStatementSuffixMergeFiles
|
||||
@ -1718,11 +1722,6 @@ tableAllColumns
|
||||
| tableOrView DOT STAR
|
||||
;
|
||||
|
||||
// (table|column)
|
||||
tableOrColumn
|
||||
: id_
|
||||
;
|
||||
|
||||
defaultValue
|
||||
: KW_DEFAULT
|
||||
;
|
||||
@ -1964,7 +1963,7 @@ selectTrfmClause
|
||||
|
||||
selectItem
|
||||
: tableAllColumns
|
||||
| (expression (KW_AS? id_ | KW_AS LPAREN id_ (COMMA id_)* RPAREN)?)
|
||||
| ((columnName | expression) (KW_AS? id_ | KW_AS LPAREN id_ (COMMA id_)* RPAREN)?)
|
||||
;
|
||||
|
||||
trfmClause
|
||||
@ -2035,7 +2034,8 @@ groupByClause
|
||||
|
||||
// support for new and old rollup/cube syntax
|
||||
groupby_expression
|
||||
: rollupStandard
|
||||
: columnName
|
||||
| rollupStandard
|
||||
| rollupOldSyntax
|
||||
| groupByEmpty
|
||||
;
|
||||
@ -2339,8 +2339,8 @@ atomExpression
|
||||
| whenExpression
|
||||
| subQueryExpression
|
||||
| function_
|
||||
| tableOrColumn
|
||||
| expressionsInParenthesis
|
||||
| id_
|
||||
;
|
||||
|
||||
precedenceFieldExpression
|
||||
|
@ -238,6 +238,7 @@ KW_NANOSECOND: 'NANOSECOND';
|
||||
KW_NANOSECONDS: 'NANOSECONDS';
|
||||
KW_NATURAL: 'NATURAL';
|
||||
KW_NO: 'NO';
|
||||
KW_NOSCAN: 'NOSCAN';
|
||||
KW_NOT: 'NOT';
|
||||
KW_NULL: 'NULL';
|
||||
KW_NULLS: 'NULLS';
|
||||
|
@ -22,30 +22,6 @@ parser grammar SparkSqlParser;
|
||||
|
||||
options { tokenVocab = SparkSqlLexer; }
|
||||
|
||||
@members {
|
||||
/**
|
||||
* When false, KW_INTERSECT is given the greater precedence over the other set
|
||||
* operations (KW_UNION, KW_EXCEPT and MINUS) as per the SQL standard.
|
||||
*/
|
||||
public legacy_setops_precedence_enabled = false;
|
||||
|
||||
/**
|
||||
* When false, a literal with an exponent would be converted into
|
||||
* double type rather than decimal type.
|
||||
*/
|
||||
public legacy_exponent_literal_as_decimal_enabled = false;
|
||||
|
||||
/**
|
||||
* When true, the behavior of keywords follows ANSI SQL standard.
|
||||
*/
|
||||
public SQL_standard_keyword_behavior = false;
|
||||
|
||||
/**
|
||||
* When true, double quoted literals are identifiers rather than STRINGs.
|
||||
*/
|
||||
public double_quoted_identifiers = false;
|
||||
}
|
||||
|
||||
program
|
||||
: singleStatement* EOF
|
||||
;
|
||||
@ -86,24 +62,19 @@ statement
|
||||
createTableClauses
|
||||
(KW_AS? query)?
|
||||
| KW_ANALYZE KW_TABLE tableName partitionSpec? KW_COMPUTE KW_STATISTICS
|
||||
(identifier | KW_FOR KW_COLUMNS identifierSeq | KW_FOR KW_ALL KW_COLUMNS)?
|
||||
(KW_NOSCAN | KW_FOR KW_COLUMNS columnNameSeq | KW_FOR KW_ALL KW_COLUMNS)?
|
||||
| KW_ANALYZE KW_TABLES ((KW_FROM | KW_IN) dbSchemaName)? KW_COMPUTE KW_STATISTICS
|
||||
(identifier)?
|
||||
(KW_NOSCAN)?
|
||||
| KW_ALTER KW_TABLE tableName
|
||||
KW_ADD (KW_COLUMN | KW_COLUMNS)
|
||||
qualifiedColTypeWithPositionList
|
||||
KW_ADD KW_COLUMN qualifiedColTypeWithPositionForAdd
|
||||
| KW_ALTER KW_TABLE tableName
|
||||
KW_ADD (KW_COLUMN | KW_COLUMNS)
|
||||
LEFT_PAREN qualifiedColTypeWithPositionList RIGHT_PAREN
|
||||
KW_ADD KW_COLUMNS LEFT_PAREN qualifiedColTypeWithPositionSeqForAdd RIGHT_PAREN
|
||||
| KW_ALTER KW_TABLE table=tableName
|
||||
KW_RENAME KW_COLUMN
|
||||
multipartIdentifier KW_TO errorCapturingIdentifier
|
||||
KW_RENAME KW_COLUMN columnName KW_TO columnNameCreate
|
||||
| KW_ALTER KW_TABLE tableName
|
||||
KW_DROP (KW_COLUMN | KW_COLUMNS) (ifExists)?
|
||||
LEFT_PAREN multipartIdentifierList RIGHT_PAREN
|
||||
KW_DROP KW_COLUMN (ifExists)? columnName
|
||||
| KW_ALTER KW_TABLE tableName
|
||||
KW_DROP (KW_COLUMN | KW_COLUMNS) (ifExists)?
|
||||
multipartIdentifierList
|
||||
KW_DROP KW_COLUMNS (ifExists)? LEFT_PAREN columnNameSeq RIGHT_PAREN
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName)
|
||||
KW_RENAME KW_TO multipartIdentifier
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName)
|
||||
@ -111,14 +82,14 @@ statement
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName)
|
||||
KW_UNSET KW_TBLPROPERTIES (ifExists)? propertyList
|
||||
| KW_ALTER KW_TABLE table=tableName
|
||||
(KW_ALTER | KW_CHANGE) KW_COLUMN? column=multipartIdentifier
|
||||
(KW_ALTER | KW_CHANGE) KW_COLUMN? column=columnName
|
||||
alterColumnAction?
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec?
|
||||
KW_CHANGE KW_COLUMN?
|
||||
colName=multipartIdentifier colType colPosition?
|
||||
colName=columnName colType colPosition?
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec?
|
||||
KW_REPLACE KW_COLUMNS
|
||||
LEFT_PAREN qualifiedColTypeWithPositionList
|
||||
LEFT_PAREN qualifiedColTypeWithPositionSeqForReplace
|
||||
RIGHT_PAREN
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)?
|
||||
KW_SET KW_SERDE stringLit (KW_WITH KW_SERDEPROPERTIES propertyList)?
|
||||
@ -162,7 +133,7 @@ statement
|
||||
| KW_SHOW KW_TBLPROPERTIES table=tableName
|
||||
(LEFT_PAREN key=propertyKey RIGHT_PAREN)?
|
||||
| KW_SHOW KW_COLUMNS (KW_FROM | KW_IN) table=tableName
|
||||
((KW_FROM | KW_IN) multipartIdentifier)?
|
||||
((KW_FROM | KW_IN) dbSchemaName)?
|
||||
| KW_SHOW KW_VIEWS ((KW_FROM | KW_IN) dbSchemaName)?
|
||||
(KW_LIKE? pattern=stringLit)?
|
||||
| KW_SHOW KW_PARTITIONS tableName partitionSpec?
|
||||
@ -306,8 +277,8 @@ query
|
||||
;
|
||||
|
||||
insertInto
|
||||
: KW_INSERT KW_OVERWRITE KW_TABLE? tableName (partitionSpec (ifNotExists)?)? ((KW_BY KW_NAME) | identifierList)?
|
||||
| KW_INSERT KW_INTO KW_TABLE? tableName partitionSpec? (ifNotExists)? ((KW_BY KW_NAME) | identifierList)?
|
||||
: KW_INSERT KW_OVERWRITE KW_TABLE? tableName (partitionSpec (ifNotExists)?)? ((KW_BY KW_NAME) | (LEFT_PAREN columnNameSeq RIGHT_PAREN ))?
|
||||
| KW_INSERT KW_INTO KW_TABLE? tableName partitionSpec? (ifNotExists)? ((KW_BY KW_NAME) | (LEFT_PAREN columnNameSeq RIGHT_PAREN ))?
|
||||
| KW_INSERT KW_INTO KW_TABLE? tableName KW_REPLACE whereClause
|
||||
| KW_INSERT KW_OVERWRITE KW_LOCAL? KW_DIRECTORY path=stringLit rowFormat? createFileFormat?
|
||||
| KW_INSERT KW_OVERWRITE KW_LOCAL? KW_DIRECTORY (path=stringLit)? tableProvider (KW_OPTIONS options=propertyList)?
|
||||
@ -443,11 +414,22 @@ dmlStatementNoWith
|
||||
;
|
||||
|
||||
dbSchemaName: identifierReference;
|
||||
|
||||
dbSchemaNameCreate: identifierReference;
|
||||
tableNameCreate : tableIdentifier;
|
||||
tableName : tableIdentifier;
|
||||
viewNameCreate : viewIdentifier;
|
||||
viewName : viewIdentifier;
|
||||
|
||||
tableNameCreate: tableIdentifier;
|
||||
|
||||
tableName: tableIdentifier;
|
||||
|
||||
viewNameCreate: viewIdentifier;
|
||||
|
||||
viewName: viewIdentifier;
|
||||
|
||||
columnName: multipartIdentifier;
|
||||
|
||||
columnNameSeq: columnName (COMMA columnName)* ;
|
||||
|
||||
columnNameCreate: errorCapturingIdentifier;
|
||||
|
||||
identifierReference
|
||||
: KW_IDENTIFIER LEFT_PAREN expression RIGHT_PAREN
|
||||
@ -470,11 +452,11 @@ multiInsertQueryBody
|
||||
|
||||
queryTerm
|
||||
: queryPrimary
|
||||
| left=queryTerm {this.legacy_setops_precedence_enabled}?
|
||||
| left=queryTerm
|
||||
operator=(KW_INTERSECT | KW_UNION | KW_EXCEPT | KW_MINUS) setQuantifier? right=queryTerm
|
||||
| left=queryTerm {!this.legacy_setops_precedence_enabled}?
|
||||
| left=queryTerm
|
||||
operator=KW_INTERSECT setQuantifier? right=queryTerm
|
||||
| left=queryTerm {!this.legacy_setops_precedence_enabled}?
|
||||
| left=queryTerm
|
||||
operator=(KW_UNION | KW_EXCEPT | KW_MINUS) setQuantifier? right=queryTerm
|
||||
;
|
||||
|
||||
@ -487,7 +469,7 @@ queryPrimary
|
||||
;
|
||||
|
||||
sortItem
|
||||
: expression ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
|
||||
: (columnName | expression) ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
|
||||
;
|
||||
|
||||
fromStatement
|
||||
@ -620,7 +602,8 @@ aggregationClause
|
||||
;
|
||||
|
||||
groupByClause
|
||||
: groupingAnalytics
|
||||
: columnName
|
||||
| groupingAnalytics
|
||||
| expression
|
||||
;
|
||||
|
||||
@ -635,8 +618,9 @@ groupingElement
|
||||
;
|
||||
|
||||
groupingSet
|
||||
: LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
|
||||
: columnName
|
||||
| expression
|
||||
| LEFT_PAREN ((columnName | expression) (COMMA (columnName | expression))*)? RIGHT_PAREN
|
||||
;
|
||||
|
||||
pivotClause
|
||||
@ -870,7 +854,7 @@ viewIdentifier
|
||||
;
|
||||
|
||||
namedExpression
|
||||
: expression (KW_AS? (name=errorCapturingIdentifier | identifierList))?
|
||||
: (columnName | expression) (KW_AS? (name=errorCapturingIdentifier | identifierList))?
|
||||
;
|
||||
|
||||
namedExpressionSeq
|
||||
@ -1097,14 +1081,23 @@ dataType
|
||||
(COMMA INTEGER_VALUE)* RIGHT_PAREN)?
|
||||
;
|
||||
|
||||
qualifiedColTypeWithPositionList
|
||||
: qualifiedColTypeWithPosition (COMMA qualifiedColTypeWithPosition)*
|
||||
qualifiedColTypeWithPositionSeqForAdd
|
||||
: qualifiedColTypeWithPositionForAdd (COMMA qualifiedColTypeWithPositionForAdd)*
|
||||
;
|
||||
|
||||
qualifiedColTypeWithPosition
|
||||
: name=multipartIdentifier dataType colDefinitionDescriptorWithPosition*
|
||||
qualifiedColTypeWithPositionForAdd
|
||||
: name=columnNameCreate dataType colDefinitionDescriptorWithPosition*
|
||||
;
|
||||
|
||||
qualifiedColTypeWithPositionSeqForReplace
|
||||
: qualifiedColTypeWithPositionForReplace (COMMA qualifiedColTypeWithPositionForReplace)*
|
||||
;
|
||||
|
||||
qualifiedColTypeWithPositionForReplace
|
||||
: name=columnName dataType colDefinitionDescriptorWithPosition*
|
||||
;
|
||||
|
||||
|
||||
colDefinitionDescriptorWithPosition
|
||||
: KW_NOT KW_NULL
|
||||
| defaultExpression
|
||||
@ -1133,7 +1126,7 @@ createOrReplaceTableColTypeList
|
||||
;
|
||||
|
||||
createOrReplaceTableColType
|
||||
: colName=errorCapturingIdentifier dataType colDefinitionOption*
|
||||
: colName=columnNameCreate dataType colDefinitionOption*
|
||||
;
|
||||
|
||||
colDefinitionOption
|
||||
@ -1230,19 +1223,19 @@ errorCapturingIdentifierExtra
|
||||
|
||||
identifier
|
||||
: strictIdentifier
|
||||
| {!this.SQL_standard_keyword_behavior}? strictNonReserved
|
||||
| strictNonReserved
|
||||
;
|
||||
|
||||
strictIdentifier
|
||||
: IDENTIFIER
|
||||
| quotedIdentifier
|
||||
| {this.SQL_standard_keyword_behavior}? ansiNonReserved
|
||||
| {!this.SQL_standard_keyword_behavior}? nonReserved
|
||||
| ansiNonReserved
|
||||
| nonReserved
|
||||
;
|
||||
|
||||
quotedIdentifier
|
||||
: BACKQUOTED_IDENTIFIER
|
||||
| {this.double_quoted_identifiers}? DOUBLEQUOTED_STRING
|
||||
| DOUBLEQUOTED_STRING
|
||||
;
|
||||
|
||||
backQuotedIdentifier
|
||||
@ -1250,9 +1243,9 @@ backQuotedIdentifier
|
||||
;
|
||||
|
||||
number
|
||||
: {!this.legacy_exponent_literal_as_decimal_enabled}? MINUS? EXPONENT_VALUE
|
||||
| {!this.legacy_exponent_literal_as_decimal_enabled}? MINUS? DECIMAL_VALUE
|
||||
| {this.legacy_exponent_literal_as_decimal_enabled}? MINUS? (EXPONENT_VALUE | DECIMAL_VALUE)
|
||||
: MINUS? EXPONENT_VALUE
|
||||
| MINUS? DECIMAL_VALUE
|
||||
| MINUS? (EXPONENT_VALUE | DECIMAL_VALUE)
|
||||
| MINUS? INTEGER_VALUE
|
||||
| MINUS? BIGINT_LITERAL
|
||||
| MINUS? SMALLINT_LITERAL
|
||||
@ -1273,7 +1266,7 @@ alterColumnAction
|
||||
|
||||
stringLit
|
||||
: STRING_LITERAL
|
||||
| {!this.double_quoted_identifiers}? DOUBLEQUOTED_STRING
|
||||
| DOUBLEQUOTED_STRING
|
||||
;
|
||||
|
||||
comment
|
||||
|
@ -52,7 +52,7 @@ statement:
|
||||
| KW_DROP KW_SCHEMA (KW_IF KW_EXISTS)? schemaName (KW_CASCADE | KW_RESTRICT)? # dropSchema
|
||||
| KW_ALTER KW_SCHEMA schemaName KW_RENAME KW_TO schemaNameCreate # renameSchema
|
||||
| KW_ALTER KW_SCHEMA schemaName KW_SET KW_AUTHORIZATION principal # setSchemaAuthorization
|
||||
| KW_CREATE KW_TABLE (KW_IF KW_NOT KW_EXISTS)? tableNameCreate columnAliases? (
|
||||
| KW_CREATE KW_TABLE (KW_IF KW_NOT KW_EXISTS)? tableNameCreate columnListCreate? (
|
||||
KW_COMMENT string
|
||||
)? (KW_WITH properties)? KW_AS (query | '(' query ')') (
|
||||
KW_WITH (KW_NO)? KW_DATA
|
||||
@ -61,18 +61,18 @@ statement:
|
||||
',' tableElement
|
||||
)* ')' (KW_COMMENT string)? (KW_WITH properties)? # createTable
|
||||
| KW_DROP KW_TABLE (KW_IF KW_EXISTS)? tableName # dropTable
|
||||
| KW_INSERT KW_INTO tableName columnAliases? query # insertInto
|
||||
| KW_INSERT KW_INTO tableName columnList? query # insertInto
|
||||
| KW_DELETE KW_FROM tableName (KW_WHERE booleanExpression)? # delete
|
||||
| KW_TRUNCATE KW_TABLE tableName # truncateTable
|
||||
| KW_ALTER KW_TABLE (KW_IF KW_EXISTS)? from = tableName KW_RENAME KW_TO to = tableNameCreate # renameTable
|
||||
| KW_COMMENT KW_ON KW_TABLE tableName KW_IS (string | KW_NULL) # commentTable
|
||||
| KW_COMMENT KW_ON KW_COLUMN qualifiedName KW_IS (string | KW_NULL) # commentColumn
|
||||
| KW_COMMENT KW_ON KW_COLUMN columnName KW_IS (string | KW_NULL) # commentColumn
|
||||
| KW_ALTER KW_TABLE (KW_IF KW_EXISTS)? tableName KW_RENAME KW_COLUMN (
|
||||
KW_IF KW_EXISTS
|
||||
)? from = identifier KW_TO to = identifier # renameColumn
|
||||
)? from = columnName KW_TO to = columnNameCreate # renameColumn
|
||||
| KW_ALTER KW_TABLE (KW_IF KW_EXISTS)? tableName KW_DROP KW_COLUMN (
|
||||
KW_IF KW_EXISTS
|
||||
)? column = qualifiedName # dropColumn
|
||||
)? column = columnName # dropColumn
|
||||
| KW_ALTER KW_TABLE (KW_IF KW_EXISTS)? tableName KW_ADD KW_COLUMN (
|
||||
KW_IF KW_NOT KW_EXISTS
|
||||
)? column = columnDefinition # addColumn
|
||||
@ -173,7 +173,7 @@ statement:
|
||||
)* (KW_WHERE where = booleanExpression)? # update
|
||||
| KW_MERGE KW_INTO tableName (KW_AS? identifier)? KW_USING relation KW_ON expression mergeCase+ # merge
|
||||
| KW_SHOW KW_COMMENT KW_ON KW_TABLE tableName # showTableComment
|
||||
| KW_SHOW KW_COMMENT KW_ON KW_COLUMN qualifiedName # showColumnComment;
|
||||
| KW_SHOW KW_COMMENT KW_ON KW_COLUMN columnName # showColumnComment;
|
||||
|
||||
query: with? queryNoWith;
|
||||
|
||||
@ -182,7 +182,7 @@ with: KW_WITH KW_RECURSIVE? namedQuery (',' namedQuery)*;
|
||||
tableElement: columnDefinition | likeClause;
|
||||
|
||||
columnDefinition:
|
||||
identifier type (KW_NOT KW_NULL)? (KW_COMMENT string)? (
|
||||
columnNameCreate type (KW_NOT KW_NULL)? (KW_COMMENT string)? (
|
||||
KW_WITH properties
|
||||
)?;
|
||||
|
||||
@ -230,7 +230,7 @@ queryPrimary:
|
||||
| '(' queryNoWith ')' # subquery;
|
||||
|
||||
sortItem:
|
||||
expression ordering = (KW_ASC | KW_DESC)? (
|
||||
(columnName | expression) ordering = (KW_ASC | KW_DESC)? (
|
||||
KW_NULLS nullOrdering = (KW_FIRST | KW_LAST)
|
||||
)?;
|
||||
|
||||
@ -245,12 +245,16 @@ groupBy: setQuantifier? groupingElement (',' groupingElement)*;
|
||||
|
||||
groupingElement:
|
||||
groupingSet # singleGroupingSet
|
||||
| KW_ROLLUP '(' (expression (',' expression)*)? ')' # rollup
|
||||
| KW_CUBE '(' (expression (',' expression)*)? ')' # cube
|
||||
| KW_ROLLUP '(' (groupingTerm (',' groupingTerm)*)? ')' # rollup
|
||||
| KW_CUBE '(' (groupingTerm (',' groupingTerm)*)? ')' # cube
|
||||
| KW_GROUPING KW_SETS '(' groupingSet (',' groupingSet)* ')' # multipleGroupingSets;
|
||||
|
||||
groupingSet:
|
||||
'(' (expression (',' expression)*)? ')'
|
||||
'(' (groupingTerm (',' groupingTerm)*)? ')'
|
||||
| groupingTerm;
|
||||
|
||||
groupingTerm:
|
||||
columnName
|
||||
| expression;
|
||||
|
||||
windowDefinition:
|
||||
@ -267,7 +271,7 @@ namedQuery: name = identifier (columnAliases)? KW_AS '(' query ')';
|
||||
setQuantifier: KW_DISTINCT | KW_ALL;
|
||||
|
||||
selectItem:
|
||||
expression (KW_AS? identifier)? # selectSingle
|
||||
(columnName | expression) (KW_AS? identifier)? # selectSingle
|
||||
| primaryExpression '.' ASTERISK (KW_AS columnAliases)? # selectAll
|
||||
| ASTERISK # selectAll;
|
||||
|
||||
@ -335,6 +339,10 @@ variableDefinition: identifier KW_AS expression;
|
||||
aliasedRelation:
|
||||
relationPrimary (KW_AS? identifier columnAliases?)?;
|
||||
|
||||
columnListCreate: '(' columnNameCreate (',' columnNameCreate)* ')';
|
||||
|
||||
columnList: '(' columnName (',' columnName)* ')';
|
||||
|
||||
columnAliases: '(' identifier (',' identifier)* ')';
|
||||
|
||||
relationPrimary:
|
||||
@ -611,6 +619,10 @@ catalogNameCreate: catalog = identifier;
|
||||
|
||||
functionName: qualifiedName;
|
||||
|
||||
columnName: qualifiedName ;
|
||||
|
||||
columnNameCreate: identifier;
|
||||
|
||||
qualifiedName: identifier ('.' identifier)*;
|
||||
|
||||
grantor:
|
||||
|
Reference in New Issue
Block a user