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:
Hayden 2023-11-28 21:18:44 +08:00 committed by GitHub
parent 3dadc0c4b5
commit 31a811d1bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 24223 additions and 20737 deletions

View File

@ -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

View File

@ -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

View File

@ -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';

View File

@ -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

View File

@ -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:

View File

@ -1,4 +1,4 @@
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/flinksql/FlinkSqlLexer.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlLexer.g4 by ANTLR 4.9.0-SNAPSHOT
import { ATN } from "antlr4ts/atn/ATN";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
@ -28,6 +28,7 @@ import { DateFunctionExpressionContext } from "./FlinkSqlParser";
import { ErrorIdentContext } from "./FlinkSqlParser";
import { RealIdentContext } from "./FlinkSqlParser";
import { IdentityTransformContext } from "./FlinkSqlParser";
import { ColumnTransformContext } from "./FlinkSqlParser";
import { ApplyTransformContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser";
import { ExistsContext } from "./FlinkSqlParser";
@ -60,6 +61,7 @@ import { SimpleCreateTableContext } from "./FlinkSqlParser";
import { CreateTableAsSelectContext } from "./FlinkSqlParser";
import { ColumnOptionDefinitionContext } from "./FlinkSqlParser";
import { PhysicalColumnDefinitionContext } from "./FlinkSqlParser";
import { ColumnNameCreateContext } from "./FlinkSqlParser";
import { ColumnNameContext } from "./FlinkSqlParser";
import { ColumnNameListContext } from "./FlinkSqlParser";
import { ColumnTypeContext } from "./FlinkSqlParser";
@ -554,6 +556,19 @@ export interface FlinkSqlParserListener extends ParseTreeListener {
*/
exitIdentityTransform?: (ctx: IdentityTransformContext) => void;
/**
* Enter a parse tree produced by the `columnTransform`
* labeled alternative in `FlinkSqlParser.transform`.
* @param ctx the parse tree
*/
enterColumnTransform?: (ctx: ColumnTransformContext) => void;
/**
* Exit a parse tree produced by the `columnTransform`
* labeled alternative in `FlinkSqlParser.transform`.
* @param ctx the parse tree
*/
exitColumnTransform?: (ctx: ColumnTransformContext) => void;
/**
* Enter a parse tree produced by the `applyTransform`
* labeled alternative in `FlinkSqlParser.transform`.
@ -918,6 +933,17 @@ export interface FlinkSqlParserListener extends ParseTreeListener {
*/
exitPhysicalColumnDefinition?: (ctx: PhysicalColumnDefinitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
enterColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
exitColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.columnName`.
* @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
@ -28,6 +28,7 @@ import { DateFunctionExpressionContext } from "./FlinkSqlParser";
import { ErrorIdentContext } from "./FlinkSqlParser";
import { RealIdentContext } from "./FlinkSqlParser";
import { IdentityTransformContext } from "./FlinkSqlParser";
import { ColumnTransformContext } from "./FlinkSqlParser";
import { ApplyTransformContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser";
import { ExistsContext } from "./FlinkSqlParser";
@ -60,6 +61,7 @@ import { SimpleCreateTableContext } from "./FlinkSqlParser";
import { CreateTableAsSelectContext } from "./FlinkSqlParser";
import { ColumnOptionDefinitionContext } from "./FlinkSqlParser";
import { PhysicalColumnDefinitionContext } from "./FlinkSqlParser";
import { ColumnNameCreateContext } from "./FlinkSqlParser";
import { ColumnNameContext } from "./FlinkSqlParser";
import { ColumnNameListContext } from "./FlinkSqlParser";
import { ColumnTypeContext } from "./FlinkSqlParser";
@ -432,6 +434,14 @@ export interface FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Result>
*/
visitIdentityTransform?: (ctx: IdentityTransformContext) => Result;
/**
* Visit a parse tree produced by the `columnTransform`
* labeled alternative in `FlinkSqlParser.transform`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnTransform?: (ctx: ColumnTransformContext) => Result;
/**
* Visit a parse tree produced by the `applyTransform`
* labeled alternative in `FlinkSqlParser.transform`.
@ -662,6 +672,13 @@ export interface FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Result>
*/
visitPhysicalColumnDefinition?: (ctx: PhysicalColumnDefinitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.columnNameCreate`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnNameCreate?: (ctx: ColumnNameCreateContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.columnName`.
* @param ctx the parse tree

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -145,6 +145,7 @@ import { ColumnNameTypeOrConstraintListContext } from "./HiveSqlParser";
import { ColumnNameColonTypeListContext } from "./HiveSqlParser";
import { ColumnNameListContext } from "./HiveSqlParser";
import { ColumnNameContext } from "./HiveSqlParser";
import { ColumnNameCreateContext } from "./HiveSqlParser";
import { ExtColumnNameContext } from "./HiveSqlParser";
import { ColumnNameOrderListContext } from "./HiveSqlParser";
import { ColumnParenthesesListContext } from "./HiveSqlParser";
@ -309,7 +310,6 @@ import { DataConnectorTypeContext } from "./HiveSqlParser";
import { DcPropertiesContext } from "./HiveSqlParser";
import { DropDataConnectorStatementContext } from "./HiveSqlParser";
import { TableAllColumnsContext } from "./HiveSqlParser";
import { TableOrColumnContext } from "./HiveSqlParser";
import { DefaultValueContext } from "./HiveSqlParser";
import { ExpressionListContext } from "./HiveSqlParser";
import { AliasListContext } from "./HiveSqlParser";
@ -2093,6 +2093,17 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitColumnName?: (ctx: ColumnNameContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
enterColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
exitColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.extColumnName`.
* @param ctx the parse tree
@ -3897,17 +3908,6 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitTableAllColumns?: (ctx: TableAllColumnsContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.tableOrColumn`.
* @param ctx the parse tree
*/
enterTableOrColumn?: (ctx: TableOrColumnContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.tableOrColumn`.
* @param ctx the parse tree
*/
exitTableOrColumn?: (ctx: TableOrColumnContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.defaultValue`.
* @param ctx the parse tree

View File

@ -145,6 +145,7 @@ import { ColumnNameTypeOrConstraintListContext } from "./HiveSqlParser";
import { ColumnNameColonTypeListContext } from "./HiveSqlParser";
import { ColumnNameListContext } from "./HiveSqlParser";
import { ColumnNameContext } from "./HiveSqlParser";
import { ColumnNameCreateContext } from "./HiveSqlParser";
import { ExtColumnNameContext } from "./HiveSqlParser";
import { ColumnNameOrderListContext } from "./HiveSqlParser";
import { ColumnParenthesesListContext } from "./HiveSqlParser";
@ -309,7 +310,6 @@ import { DataConnectorTypeContext } from "./HiveSqlParser";
import { DcPropertiesContext } from "./HiveSqlParser";
import { DropDataConnectorStatementContext } from "./HiveSqlParser";
import { TableAllColumnsContext } from "./HiveSqlParser";
import { TableOrColumnContext } from "./HiveSqlParser";
import { DefaultValueContext } from "./HiveSqlParser";
import { ExpressionListContext } from "./HiveSqlParser";
import { AliasListContext } from "./HiveSqlParser";
@ -1528,6 +1528,13 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitColumnName?: (ctx: ColumnNameContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.columnNameCreate`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnNameCreate?: (ctx: ColumnNameCreateContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.extColumnName`.
* @param ctx the parse tree
@ -2676,13 +2683,6 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitTableAllColumns?: (ctx: TableAllColumnsContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.tableOrColumn`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTableOrColumn?: (ctx: TableOrColumnContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.defaultValue`.
* @param ctx the parse tree

File diff suppressed because one or more lines are too long

View File

@ -189,200 +189,201 @@ KW_NANOSECOND=188
KW_NANOSECONDS=189
KW_NATURAL=190
KW_NO=191
KW_NOT=192
KW_NULL=193
KW_NULLS=194
KW_NUMERIC=195
KW_OF=196
KW_OFFSET=197
KW_ON=198
KW_ONLY=199
KW_OPTION=200
KW_OPTIONS=201
KW_OR=202
KW_ORDER=203
KW_OUT=204
KW_OUTER=205
KW_OUTPUTFORMAT=206
KW_OVER=207
KW_OVERLAPS=208
KW_OVERLAY=209
KW_OVERWRITE=210
KW_PARTITION=211
KW_PARTITIONED=212
KW_PARTITIONS=213
KW_PERCENTILE_CONT=214
KW_PERCENTILE_DISC=215
KW_PERCENTLIT=216
KW_PIVOT=217
KW_PLACING=218
KW_POSITION=219
KW_PRECEDING=220
KW_PRIMARY=221
KW_PRINCIPALS=222
KW_PROPERTIES=223
KW_PURGE=224
KW_QUARTER=225
KW_QUERY=226
KW_RANGE=227
KW_REAL=228
KW_RECORDREADER=229
KW_RECORDWRITER=230
KW_RECOVER=231
KW_REDUCE=232
KW_REFERENCES=233
KW_REFRESH=234
KW_RENAME=235
KW_REPAIR=236
KW_REPEATABLE=237
KW_REPLACE=238
KW_RESET=239
KW_RESPECT=240
KW_RESTRICT=241
KW_REVOKE=242
KW_RIGHT=243
KW_RLIKE=244
KW_REGEXP=245
KW_ROLE=246
KW_ROLES=247
KW_ROLLBACK=248
KW_ROLLUP=249
KW_ROW=250
KW_ROWS=251
KW_SECOND=252
KW_SECONDS=253
KW_SCHEMA=254
KW_SCHEMAS=255
KW_SELECT=256
KW_SEMI=257
KW_SEPARATED=258
KW_SERDE=259
KW_SERDEPROPERTIES=260
KW_SESSION_USER=261
KW_SET=262
KW_MINUS=263
KW_SETS=264
KW_SHORT=265
KW_SHOW=266
KW_SINGLE=267
KW_SKEWED=268
KW_SMALLINT=269
KW_SOME=270
KW_SORT=271
KW_SORTED=272
KW_SOURCE=273
KW_START=274
KW_STATISTICS=275
KW_STORED=276
KW_STRATIFY=277
KW_STRING=278
KW_STRUCT=279
KW_SUBSTR=280
KW_SUBSTRING=281
KW_SYNC=282
KW_SYSTEM=283
KW_SYSTEM_TIME=284
KW_SYSTEM_VERSION=285
KW_TABLE=286
KW_TABLES=287
KW_TABLESAMPLE=288
KW_TARGET=289
KW_TBLPROPERTIES=290
KW_TEMPORARY=291
KW_TERMINATED=292
KW_THEN=293
KW_TIME=294
KW_TIMEDIFF=295
KW_TIMESTAMP=296
KW_TIMESTAMP_LTZ=297
KW_TIMESTAMP_NTZ=298
KW_TIMESTAMPADD=299
KW_TIMESTAMPDIFF=300
KW_TINYINT=301
KW_TO=302
KW_TOUCH=303
KW_TRAILING=304
KW_TRANSACTION=305
KW_TRANSACTIONS=306
KW_TRANSFORM=307
KW_TRIM=308
KW_TRUE=309
KW_TRUNCATE=310
KW_TRY_CAST=311
KW_TYPE=312
KW_UNARCHIVE=313
KW_UNBOUNDED=314
KW_UNCACHE=315
KW_UNION=316
KW_UNIQUE=317
KW_UNKNOWN=318
KW_UNLOCK=319
KW_UNPIVOT=320
KW_UNSET=321
KW_UPDATE=322
KW_USE=323
KW_USER=324
KW_USING=325
KW_VALUES=326
KW_VARCHAR=327
KW_VAR=328
KW_VARIABLE=329
KW_VERSION=330
KW_VIEW=331
KW_VIEWS=332
KW_VOID=333
KW_WEEK=334
KW_WEEKS=335
KW_WHEN=336
KW_WHERE=337
KW_WINDOW=338
KW_WITH=339
KW_WITHIN=340
KW_YEAR=341
KW_YEARS=342
KW_ZONE=343
EQ=344
NSEQ=345
NEQ=346
NEQJ=347
LT=348
LTE=349
GT=350
GTE=351
NOT=352
PLUS=353
MINUS=354
ASTERISK=355
SLASH=356
PERCENT=357
TILDE=358
AMPERSAND=359
PIPE=360
CONCAT_PIPE=361
HAT=362
COLON=363
ARROW=364
FAT_ARROW=365
HENT_START=366
HENT_END=367
QUESTION=368
STRING_LITERAL=369
DOUBLEQUOTED_STRING=370
BIGINT_LITERAL=371
SMALLINT_LITERAL=372
TINYINT_LITERAL=373
INTEGER_VALUE=374
EXPONENT_VALUE=375
DECIMAL_VALUE=376
FLOAT_LITERAL=377
DOUBLE_LITERAL=378
BIGDECIMAL_LITERAL=379
IDENTIFIER=380
BACKQUOTED_IDENTIFIER=381
SIMPLE_COMMENT=382
BRACKETED_COMMENT=383
WS=384
UNRECOGNIZED=385
KW_NOSCAN=192
KW_NOT=193
KW_NULL=194
KW_NULLS=195
KW_NUMERIC=196
KW_OF=197
KW_OFFSET=198
KW_ON=199
KW_ONLY=200
KW_OPTION=201
KW_OPTIONS=202
KW_OR=203
KW_ORDER=204
KW_OUT=205
KW_OUTER=206
KW_OUTPUTFORMAT=207
KW_OVER=208
KW_OVERLAPS=209
KW_OVERLAY=210
KW_OVERWRITE=211
KW_PARTITION=212
KW_PARTITIONED=213
KW_PARTITIONS=214
KW_PERCENTILE_CONT=215
KW_PERCENTILE_DISC=216
KW_PERCENTLIT=217
KW_PIVOT=218
KW_PLACING=219
KW_POSITION=220
KW_PRECEDING=221
KW_PRIMARY=222
KW_PRINCIPALS=223
KW_PROPERTIES=224
KW_PURGE=225
KW_QUARTER=226
KW_QUERY=227
KW_RANGE=228
KW_REAL=229
KW_RECORDREADER=230
KW_RECORDWRITER=231
KW_RECOVER=232
KW_REDUCE=233
KW_REFERENCES=234
KW_REFRESH=235
KW_RENAME=236
KW_REPAIR=237
KW_REPEATABLE=238
KW_REPLACE=239
KW_RESET=240
KW_RESPECT=241
KW_RESTRICT=242
KW_REVOKE=243
KW_RIGHT=244
KW_RLIKE=245
KW_REGEXP=246
KW_ROLE=247
KW_ROLES=248
KW_ROLLBACK=249
KW_ROLLUP=250
KW_ROW=251
KW_ROWS=252
KW_SECOND=253
KW_SECONDS=254
KW_SCHEMA=255
KW_SCHEMAS=256
KW_SELECT=257
KW_SEMI=258
KW_SEPARATED=259
KW_SERDE=260
KW_SERDEPROPERTIES=261
KW_SESSION_USER=262
KW_SET=263
KW_MINUS=264
KW_SETS=265
KW_SHORT=266
KW_SHOW=267
KW_SINGLE=268
KW_SKEWED=269
KW_SMALLINT=270
KW_SOME=271
KW_SORT=272
KW_SORTED=273
KW_SOURCE=274
KW_START=275
KW_STATISTICS=276
KW_STORED=277
KW_STRATIFY=278
KW_STRING=279
KW_STRUCT=280
KW_SUBSTR=281
KW_SUBSTRING=282
KW_SYNC=283
KW_SYSTEM=284
KW_SYSTEM_TIME=285
KW_SYSTEM_VERSION=286
KW_TABLE=287
KW_TABLES=288
KW_TABLESAMPLE=289
KW_TARGET=290
KW_TBLPROPERTIES=291
KW_TEMPORARY=292
KW_TERMINATED=293
KW_THEN=294
KW_TIME=295
KW_TIMEDIFF=296
KW_TIMESTAMP=297
KW_TIMESTAMP_LTZ=298
KW_TIMESTAMP_NTZ=299
KW_TIMESTAMPADD=300
KW_TIMESTAMPDIFF=301
KW_TINYINT=302
KW_TO=303
KW_TOUCH=304
KW_TRAILING=305
KW_TRANSACTION=306
KW_TRANSACTIONS=307
KW_TRANSFORM=308
KW_TRIM=309
KW_TRUE=310
KW_TRUNCATE=311
KW_TRY_CAST=312
KW_TYPE=313
KW_UNARCHIVE=314
KW_UNBOUNDED=315
KW_UNCACHE=316
KW_UNION=317
KW_UNIQUE=318
KW_UNKNOWN=319
KW_UNLOCK=320
KW_UNPIVOT=321
KW_UNSET=322
KW_UPDATE=323
KW_USE=324
KW_USER=325
KW_USING=326
KW_VALUES=327
KW_VARCHAR=328
KW_VAR=329
KW_VARIABLE=330
KW_VERSION=331
KW_VIEW=332
KW_VIEWS=333
KW_VOID=334
KW_WEEK=335
KW_WEEKS=336
KW_WHEN=337
KW_WHERE=338
KW_WINDOW=339
KW_WITH=340
KW_WITHIN=341
KW_YEAR=342
KW_YEARS=343
KW_ZONE=344
EQ=345
NSEQ=346
NEQ=347
NEQJ=348
LT=349
LTE=350
GT=351
GTE=352
NOT=353
PLUS=354
MINUS=355
ASTERISK=356
SLASH=357
PERCENT=358
TILDE=359
AMPERSAND=360
PIPE=361
CONCAT_PIPE=362
HAT=363
COLON=364
ARROW=365
FAT_ARROW=366
HENT_START=367
HENT_END=368
QUESTION=369
STRING_LITERAL=370
DOUBLEQUOTED_STRING=371
BIGINT_LITERAL=372
SMALLINT_LITERAL=373
TINYINT_LITERAL=374
INTEGER_VALUE=375
EXPONENT_VALUE=376
DECIMAL_VALUE=377
FLOAT_LITERAL=378
DOUBLE_LITERAL=379
BIGDECIMAL_LITERAL=380
IDENTIFIER=381
BACKQUOTED_IDENTIFIER=382
SIMPLE_COMMENT=383
BRACKETED_COMMENT=384
WS=385
UNRECOGNIZED=386
';'=1
'('=2
')'=3
@ -574,177 +575,178 @@ UNRECOGNIZED=385
'NANOSECONDS'=189
'NATURAL'=190
'NO'=191
'NOT'=192
'NULL'=193
'NULLS'=194
'NUMERIC'=195
'OF'=196
'OFFSET'=197
'ON'=198
'ONLY'=199
'OPTION'=200
'OPTIONS'=201
'OR'=202
'ORDER'=203
'OUT'=204
'OUTER'=205
'OUTPUTFORMAT'=206
'OVER'=207
'OVERLAPS'=208
'OVERLAY'=209
'OVERWRITE'=210
'PARTITION'=211
'PARTITIONED'=212
'PARTITIONS'=213
'PERCENTILE_CONT'=214
'PERCENTILE_DISC'=215
'PERCENT'=216
'PIVOT'=217
'PLACING'=218
'POSITION'=219
'PRECEDING'=220
'PRIMARY'=221
'PRINCIPALS'=222
'PROPERTIES'=223
'PURGE'=224
'QUARTER'=225
'QUERY'=226
'RANGE'=227
'REAL'=228
'RECORDREADER'=229
'RECORDWRITER'=230
'RECOVER'=231
'REDUCE'=232
'REFERENCES'=233
'REFRESH'=234
'RENAME'=235
'REPAIR'=236
'REPEATABLE'=237
'REPLACE'=238
'RESET'=239
'RESPECT'=240
'RESTRICT'=241
'REVOKE'=242
'RIGHT'=243
'RLIKE'=244
'REGEXP'=245
'ROLE'=246
'ROLES'=247
'ROLLBACK'=248
'ROLLUP'=249
'ROW'=250
'ROWS'=251
'SECOND'=252
'SECONDS'=253
'SCHEMA'=254
'SCHEMAS'=255
'SELECT'=256
'SEMI'=257
'SEPARATED'=258
'SERDE'=259
'SERDEPROPERTIES'=260
'SESSION_USER'=261
'SET'=262
'MINUS'=263
'SETS'=264
'SHORT'=265
'SHOW'=266
'SINGLE'=267
'SKEWED'=268
'SMALLINT'=269
'SOME'=270
'SORT'=271
'SORTED'=272
'SOURCE'=273
'START'=274
'STATISTICS'=275
'STORED'=276
'STRATIFY'=277
'STRING'=278
'STRUCT'=279
'SUBSTR'=280
'SUBSTRING'=281
'SYNC'=282
'SYSTEM'=283
'SYSTEM_TIME'=284
'SYSTEM_VERSION'=285
'TABLE'=286
'TABLES'=287
'TABLESAMPLE'=288
'TARGET'=289
'TBLPROPERTIES'=290
'TEMPORARY'=291
'TERMINATED'=292
'THEN'=293
'TIME'=294
'TIMEDIFF'=295
'TIMESTAMP'=296
'TIMESTAMP_LTZ'=297
'TIMESTAMP_NTZ'=298
'TIMESTAMPADD'=299
'TIMESTAMPDIFF'=300
'TINYINT'=301
'TO'=302
'TOUCH'=303
'TRAILING'=304
'TRANSACTION'=305
'TRANSACTIONS'=306
'TRANSFORM'=307
'TRIM'=308
'TRUE'=309
'TRUNCATE'=310
'TRY_CAST'=311
'TYPE'=312
'UNARCHIVE'=313
'UNBOUNDED'=314
'UNCACHE'=315
'UNION'=316
'UNIQUE'=317
'UNKNOWN'=318
'UNLOCK'=319
'UNPIVOT'=320
'UNSET'=321
'UPDATE'=322
'USE'=323
'USER'=324
'USING'=325
'VALUES'=326
'VARCHAR'=327
'VAR'=328
'VARIABLE'=329
'VERSION'=330
'VIEW'=331
'VIEWS'=332
'VOID'=333
'WEEK'=334
'WEEKS'=335
'WHEN'=336
'WHERE'=337
'WINDOW'=338
'WITH'=339
'WITHIN'=340
'YEAR'=341
'YEARS'=342
'ZONE'=343
'<=>'=345
'<>'=346
'!='=347
'<'=348
'>'=350
'!'=352
'+'=353
'-'=354
'*'=355
'/'=356
'%'=357
'~'=358
'&'=359
'|'=360
'||'=361
'^'=362
':'=363
'->'=364
'=>'=365
'/*+'=366
'*/'=367
'?'=368
'NOSCAN'=192
'NOT'=193
'NULL'=194
'NULLS'=195
'NUMERIC'=196
'OF'=197
'OFFSET'=198
'ON'=199
'ONLY'=200
'OPTION'=201
'OPTIONS'=202
'OR'=203
'ORDER'=204
'OUT'=205
'OUTER'=206
'OUTPUTFORMAT'=207
'OVER'=208
'OVERLAPS'=209
'OVERLAY'=210
'OVERWRITE'=211
'PARTITION'=212
'PARTITIONED'=213
'PARTITIONS'=214
'PERCENTILE_CONT'=215
'PERCENTILE_DISC'=216
'PERCENT'=217
'PIVOT'=218
'PLACING'=219
'POSITION'=220
'PRECEDING'=221
'PRIMARY'=222
'PRINCIPALS'=223
'PROPERTIES'=224
'PURGE'=225
'QUARTER'=226
'QUERY'=227
'RANGE'=228
'REAL'=229
'RECORDREADER'=230
'RECORDWRITER'=231
'RECOVER'=232
'REDUCE'=233
'REFERENCES'=234
'REFRESH'=235
'RENAME'=236
'REPAIR'=237
'REPEATABLE'=238
'REPLACE'=239
'RESET'=240
'RESPECT'=241
'RESTRICT'=242
'REVOKE'=243
'RIGHT'=244
'RLIKE'=245
'REGEXP'=246
'ROLE'=247
'ROLES'=248
'ROLLBACK'=249
'ROLLUP'=250
'ROW'=251
'ROWS'=252
'SECOND'=253
'SECONDS'=254
'SCHEMA'=255
'SCHEMAS'=256
'SELECT'=257
'SEMI'=258
'SEPARATED'=259
'SERDE'=260
'SERDEPROPERTIES'=261
'SESSION_USER'=262
'SET'=263
'MINUS'=264
'SETS'=265
'SHORT'=266
'SHOW'=267
'SINGLE'=268
'SKEWED'=269
'SMALLINT'=270
'SOME'=271
'SORT'=272
'SORTED'=273
'SOURCE'=274
'START'=275
'STATISTICS'=276
'STORED'=277
'STRATIFY'=278
'STRING'=279
'STRUCT'=280
'SUBSTR'=281
'SUBSTRING'=282
'SYNC'=283
'SYSTEM'=284
'SYSTEM_TIME'=285
'SYSTEM_VERSION'=286
'TABLE'=287
'TABLES'=288
'TABLESAMPLE'=289
'TARGET'=290
'TBLPROPERTIES'=291
'TEMPORARY'=292
'TERMINATED'=293
'THEN'=294
'TIME'=295
'TIMEDIFF'=296
'TIMESTAMP'=297
'TIMESTAMP_LTZ'=298
'TIMESTAMP_NTZ'=299
'TIMESTAMPADD'=300
'TIMESTAMPDIFF'=301
'TINYINT'=302
'TO'=303
'TOUCH'=304
'TRAILING'=305
'TRANSACTION'=306
'TRANSACTIONS'=307
'TRANSFORM'=308
'TRIM'=309
'TRUE'=310
'TRUNCATE'=311
'TRY_CAST'=312
'TYPE'=313
'UNARCHIVE'=314
'UNBOUNDED'=315
'UNCACHE'=316
'UNION'=317
'UNIQUE'=318
'UNKNOWN'=319
'UNLOCK'=320
'UNPIVOT'=321
'UNSET'=322
'UPDATE'=323
'USE'=324
'USER'=325
'USING'=326
'VALUES'=327
'VARCHAR'=328
'VAR'=329
'VARIABLE'=330
'VERSION'=331
'VIEW'=332
'VIEWS'=333
'VOID'=334
'WEEK'=335
'WEEKS'=336
'WHEN'=337
'WHERE'=338
'WINDOW'=339
'WITH'=340
'WITHIN'=341
'YEAR'=342
'YEARS'=343
'ZONE'=344
'<=>'=346
'<>'=347
'!='=348
'<'=349
'>'=351
'!'=353
'+'=354
'-'=355
'*'=356
'/'=357
'%'=358
'~'=359
'&'=360
'|'=361
'||'=362
'^'=363
':'=364
'->'=365
'=>'=366
'/*+'=367
'*/'=368
'?'=369

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -189,200 +189,201 @@ KW_NANOSECOND=188
KW_NANOSECONDS=189
KW_NATURAL=190
KW_NO=191
KW_NOT=192
KW_NULL=193
KW_NULLS=194
KW_NUMERIC=195
KW_OF=196
KW_OFFSET=197
KW_ON=198
KW_ONLY=199
KW_OPTION=200
KW_OPTIONS=201
KW_OR=202
KW_ORDER=203
KW_OUT=204
KW_OUTER=205
KW_OUTPUTFORMAT=206
KW_OVER=207
KW_OVERLAPS=208
KW_OVERLAY=209
KW_OVERWRITE=210
KW_PARTITION=211
KW_PARTITIONED=212
KW_PARTITIONS=213
KW_PERCENTILE_CONT=214
KW_PERCENTILE_DISC=215
KW_PERCENTLIT=216
KW_PIVOT=217
KW_PLACING=218
KW_POSITION=219
KW_PRECEDING=220
KW_PRIMARY=221
KW_PRINCIPALS=222
KW_PROPERTIES=223
KW_PURGE=224
KW_QUARTER=225
KW_QUERY=226
KW_RANGE=227
KW_REAL=228
KW_RECORDREADER=229
KW_RECORDWRITER=230
KW_RECOVER=231
KW_REDUCE=232
KW_REFERENCES=233
KW_REFRESH=234
KW_RENAME=235
KW_REPAIR=236
KW_REPEATABLE=237
KW_REPLACE=238
KW_RESET=239
KW_RESPECT=240
KW_RESTRICT=241
KW_REVOKE=242
KW_RIGHT=243
KW_RLIKE=244
KW_REGEXP=245
KW_ROLE=246
KW_ROLES=247
KW_ROLLBACK=248
KW_ROLLUP=249
KW_ROW=250
KW_ROWS=251
KW_SECOND=252
KW_SECONDS=253
KW_SCHEMA=254
KW_SCHEMAS=255
KW_SELECT=256
KW_SEMI=257
KW_SEPARATED=258
KW_SERDE=259
KW_SERDEPROPERTIES=260
KW_SESSION_USER=261
KW_SET=262
KW_MINUS=263
KW_SETS=264
KW_SHORT=265
KW_SHOW=266
KW_SINGLE=267
KW_SKEWED=268
KW_SMALLINT=269
KW_SOME=270
KW_SORT=271
KW_SORTED=272
KW_SOURCE=273
KW_START=274
KW_STATISTICS=275
KW_STORED=276
KW_STRATIFY=277
KW_STRING=278
KW_STRUCT=279
KW_SUBSTR=280
KW_SUBSTRING=281
KW_SYNC=282
KW_SYSTEM=283
KW_SYSTEM_TIME=284
KW_SYSTEM_VERSION=285
KW_TABLE=286
KW_TABLES=287
KW_TABLESAMPLE=288
KW_TARGET=289
KW_TBLPROPERTIES=290
KW_TEMPORARY=291
KW_TERMINATED=292
KW_THEN=293
KW_TIME=294
KW_TIMEDIFF=295
KW_TIMESTAMP=296
KW_TIMESTAMP_LTZ=297
KW_TIMESTAMP_NTZ=298
KW_TIMESTAMPADD=299
KW_TIMESTAMPDIFF=300
KW_TINYINT=301
KW_TO=302
KW_TOUCH=303
KW_TRAILING=304
KW_TRANSACTION=305
KW_TRANSACTIONS=306
KW_TRANSFORM=307
KW_TRIM=308
KW_TRUE=309
KW_TRUNCATE=310
KW_TRY_CAST=311
KW_TYPE=312
KW_UNARCHIVE=313
KW_UNBOUNDED=314
KW_UNCACHE=315
KW_UNION=316
KW_UNIQUE=317
KW_UNKNOWN=318
KW_UNLOCK=319
KW_UNPIVOT=320
KW_UNSET=321
KW_UPDATE=322
KW_USE=323
KW_USER=324
KW_USING=325
KW_VALUES=326
KW_VARCHAR=327
KW_VAR=328
KW_VARIABLE=329
KW_VERSION=330
KW_VIEW=331
KW_VIEWS=332
KW_VOID=333
KW_WEEK=334
KW_WEEKS=335
KW_WHEN=336
KW_WHERE=337
KW_WINDOW=338
KW_WITH=339
KW_WITHIN=340
KW_YEAR=341
KW_YEARS=342
KW_ZONE=343
EQ=344
NSEQ=345
NEQ=346
NEQJ=347
LT=348
LTE=349
GT=350
GTE=351
NOT=352
PLUS=353
MINUS=354
ASTERISK=355
SLASH=356
PERCENT=357
TILDE=358
AMPERSAND=359
PIPE=360
CONCAT_PIPE=361
HAT=362
COLON=363
ARROW=364
FAT_ARROW=365
HENT_START=366
HENT_END=367
QUESTION=368
STRING_LITERAL=369
DOUBLEQUOTED_STRING=370
BIGINT_LITERAL=371
SMALLINT_LITERAL=372
TINYINT_LITERAL=373
INTEGER_VALUE=374
EXPONENT_VALUE=375
DECIMAL_VALUE=376
FLOAT_LITERAL=377
DOUBLE_LITERAL=378
BIGDECIMAL_LITERAL=379
IDENTIFIER=380
BACKQUOTED_IDENTIFIER=381
SIMPLE_COMMENT=382
BRACKETED_COMMENT=383
WS=384
UNRECOGNIZED=385
KW_NOSCAN=192
KW_NOT=193
KW_NULL=194
KW_NULLS=195
KW_NUMERIC=196
KW_OF=197
KW_OFFSET=198
KW_ON=199
KW_ONLY=200
KW_OPTION=201
KW_OPTIONS=202
KW_OR=203
KW_ORDER=204
KW_OUT=205
KW_OUTER=206
KW_OUTPUTFORMAT=207
KW_OVER=208
KW_OVERLAPS=209
KW_OVERLAY=210
KW_OVERWRITE=211
KW_PARTITION=212
KW_PARTITIONED=213
KW_PARTITIONS=214
KW_PERCENTILE_CONT=215
KW_PERCENTILE_DISC=216
KW_PERCENTLIT=217
KW_PIVOT=218
KW_PLACING=219
KW_POSITION=220
KW_PRECEDING=221
KW_PRIMARY=222
KW_PRINCIPALS=223
KW_PROPERTIES=224
KW_PURGE=225
KW_QUARTER=226
KW_QUERY=227
KW_RANGE=228
KW_REAL=229
KW_RECORDREADER=230
KW_RECORDWRITER=231
KW_RECOVER=232
KW_REDUCE=233
KW_REFERENCES=234
KW_REFRESH=235
KW_RENAME=236
KW_REPAIR=237
KW_REPEATABLE=238
KW_REPLACE=239
KW_RESET=240
KW_RESPECT=241
KW_RESTRICT=242
KW_REVOKE=243
KW_RIGHT=244
KW_RLIKE=245
KW_REGEXP=246
KW_ROLE=247
KW_ROLES=248
KW_ROLLBACK=249
KW_ROLLUP=250
KW_ROW=251
KW_ROWS=252
KW_SECOND=253
KW_SECONDS=254
KW_SCHEMA=255
KW_SCHEMAS=256
KW_SELECT=257
KW_SEMI=258
KW_SEPARATED=259
KW_SERDE=260
KW_SERDEPROPERTIES=261
KW_SESSION_USER=262
KW_SET=263
KW_MINUS=264
KW_SETS=265
KW_SHORT=266
KW_SHOW=267
KW_SINGLE=268
KW_SKEWED=269
KW_SMALLINT=270
KW_SOME=271
KW_SORT=272
KW_SORTED=273
KW_SOURCE=274
KW_START=275
KW_STATISTICS=276
KW_STORED=277
KW_STRATIFY=278
KW_STRING=279
KW_STRUCT=280
KW_SUBSTR=281
KW_SUBSTRING=282
KW_SYNC=283
KW_SYSTEM=284
KW_SYSTEM_TIME=285
KW_SYSTEM_VERSION=286
KW_TABLE=287
KW_TABLES=288
KW_TABLESAMPLE=289
KW_TARGET=290
KW_TBLPROPERTIES=291
KW_TEMPORARY=292
KW_TERMINATED=293
KW_THEN=294
KW_TIME=295
KW_TIMEDIFF=296
KW_TIMESTAMP=297
KW_TIMESTAMP_LTZ=298
KW_TIMESTAMP_NTZ=299
KW_TIMESTAMPADD=300
KW_TIMESTAMPDIFF=301
KW_TINYINT=302
KW_TO=303
KW_TOUCH=304
KW_TRAILING=305
KW_TRANSACTION=306
KW_TRANSACTIONS=307
KW_TRANSFORM=308
KW_TRIM=309
KW_TRUE=310
KW_TRUNCATE=311
KW_TRY_CAST=312
KW_TYPE=313
KW_UNARCHIVE=314
KW_UNBOUNDED=315
KW_UNCACHE=316
KW_UNION=317
KW_UNIQUE=318
KW_UNKNOWN=319
KW_UNLOCK=320
KW_UNPIVOT=321
KW_UNSET=322
KW_UPDATE=323
KW_USE=324
KW_USER=325
KW_USING=326
KW_VALUES=327
KW_VARCHAR=328
KW_VAR=329
KW_VARIABLE=330
KW_VERSION=331
KW_VIEW=332
KW_VIEWS=333
KW_VOID=334
KW_WEEK=335
KW_WEEKS=336
KW_WHEN=337
KW_WHERE=338
KW_WINDOW=339
KW_WITH=340
KW_WITHIN=341
KW_YEAR=342
KW_YEARS=343
KW_ZONE=344
EQ=345
NSEQ=346
NEQ=347
NEQJ=348
LT=349
LTE=350
GT=351
GTE=352
NOT=353
PLUS=354
MINUS=355
ASTERISK=356
SLASH=357
PERCENT=358
TILDE=359
AMPERSAND=360
PIPE=361
CONCAT_PIPE=362
HAT=363
COLON=364
ARROW=365
FAT_ARROW=366
HENT_START=367
HENT_END=368
QUESTION=369
STRING_LITERAL=370
DOUBLEQUOTED_STRING=371
BIGINT_LITERAL=372
SMALLINT_LITERAL=373
TINYINT_LITERAL=374
INTEGER_VALUE=375
EXPONENT_VALUE=376
DECIMAL_VALUE=377
FLOAT_LITERAL=378
DOUBLE_LITERAL=379
BIGDECIMAL_LITERAL=380
IDENTIFIER=381
BACKQUOTED_IDENTIFIER=382
SIMPLE_COMMENT=383
BRACKETED_COMMENT=384
WS=385
UNRECOGNIZED=386
';'=1
'('=2
')'=3
@ -574,177 +575,178 @@ UNRECOGNIZED=385
'NANOSECONDS'=189
'NATURAL'=190
'NO'=191
'NOT'=192
'NULL'=193
'NULLS'=194
'NUMERIC'=195
'OF'=196
'OFFSET'=197
'ON'=198
'ONLY'=199
'OPTION'=200
'OPTIONS'=201
'OR'=202
'ORDER'=203
'OUT'=204
'OUTER'=205
'OUTPUTFORMAT'=206
'OVER'=207
'OVERLAPS'=208
'OVERLAY'=209
'OVERWRITE'=210
'PARTITION'=211
'PARTITIONED'=212
'PARTITIONS'=213
'PERCENTILE_CONT'=214
'PERCENTILE_DISC'=215
'PERCENT'=216
'PIVOT'=217
'PLACING'=218
'POSITION'=219
'PRECEDING'=220
'PRIMARY'=221
'PRINCIPALS'=222
'PROPERTIES'=223
'PURGE'=224
'QUARTER'=225
'QUERY'=226
'RANGE'=227
'REAL'=228
'RECORDREADER'=229
'RECORDWRITER'=230
'RECOVER'=231
'REDUCE'=232
'REFERENCES'=233
'REFRESH'=234
'RENAME'=235
'REPAIR'=236
'REPEATABLE'=237
'REPLACE'=238
'RESET'=239
'RESPECT'=240
'RESTRICT'=241
'REVOKE'=242
'RIGHT'=243
'RLIKE'=244
'REGEXP'=245
'ROLE'=246
'ROLES'=247
'ROLLBACK'=248
'ROLLUP'=249
'ROW'=250
'ROWS'=251
'SECOND'=252
'SECONDS'=253
'SCHEMA'=254
'SCHEMAS'=255
'SELECT'=256
'SEMI'=257
'SEPARATED'=258
'SERDE'=259
'SERDEPROPERTIES'=260
'SESSION_USER'=261
'SET'=262
'MINUS'=263
'SETS'=264
'SHORT'=265
'SHOW'=266
'SINGLE'=267
'SKEWED'=268
'SMALLINT'=269
'SOME'=270
'SORT'=271
'SORTED'=272
'SOURCE'=273
'START'=274
'STATISTICS'=275
'STORED'=276
'STRATIFY'=277
'STRING'=278
'STRUCT'=279
'SUBSTR'=280
'SUBSTRING'=281
'SYNC'=282
'SYSTEM'=283
'SYSTEM_TIME'=284
'SYSTEM_VERSION'=285
'TABLE'=286
'TABLES'=287
'TABLESAMPLE'=288
'TARGET'=289
'TBLPROPERTIES'=290
'TEMPORARY'=291
'TERMINATED'=292
'THEN'=293
'TIME'=294
'TIMEDIFF'=295
'TIMESTAMP'=296
'TIMESTAMP_LTZ'=297
'TIMESTAMP_NTZ'=298
'TIMESTAMPADD'=299
'TIMESTAMPDIFF'=300
'TINYINT'=301
'TO'=302
'TOUCH'=303
'TRAILING'=304
'TRANSACTION'=305
'TRANSACTIONS'=306
'TRANSFORM'=307
'TRIM'=308
'TRUE'=309
'TRUNCATE'=310
'TRY_CAST'=311
'TYPE'=312
'UNARCHIVE'=313
'UNBOUNDED'=314
'UNCACHE'=315
'UNION'=316
'UNIQUE'=317
'UNKNOWN'=318
'UNLOCK'=319
'UNPIVOT'=320
'UNSET'=321
'UPDATE'=322
'USE'=323
'USER'=324
'USING'=325
'VALUES'=326
'VARCHAR'=327
'VAR'=328
'VARIABLE'=329
'VERSION'=330
'VIEW'=331
'VIEWS'=332
'VOID'=333
'WEEK'=334
'WEEKS'=335
'WHEN'=336
'WHERE'=337
'WINDOW'=338
'WITH'=339
'WITHIN'=340
'YEAR'=341
'YEARS'=342
'ZONE'=343
'<=>'=345
'<>'=346
'!='=347
'<'=348
'>'=350
'!'=352
'+'=353
'-'=354
'*'=355
'/'=356
'%'=357
'~'=358
'&'=359
'|'=360
'||'=361
'^'=362
':'=363
'->'=364
'=>'=365
'/*+'=366
'*/'=367
'?'=368
'NOSCAN'=192
'NOT'=193
'NULL'=194
'NULLS'=195
'NUMERIC'=196
'OF'=197
'OFFSET'=198
'ON'=199
'ONLY'=200
'OPTION'=201
'OPTIONS'=202
'OR'=203
'ORDER'=204
'OUT'=205
'OUTER'=206
'OUTPUTFORMAT'=207
'OVER'=208
'OVERLAPS'=209
'OVERLAY'=210
'OVERWRITE'=211
'PARTITION'=212
'PARTITIONED'=213
'PARTITIONS'=214
'PERCENTILE_CONT'=215
'PERCENTILE_DISC'=216
'PERCENT'=217
'PIVOT'=218
'PLACING'=219
'POSITION'=220
'PRECEDING'=221
'PRIMARY'=222
'PRINCIPALS'=223
'PROPERTIES'=224
'PURGE'=225
'QUARTER'=226
'QUERY'=227
'RANGE'=228
'REAL'=229
'RECORDREADER'=230
'RECORDWRITER'=231
'RECOVER'=232
'REDUCE'=233
'REFERENCES'=234
'REFRESH'=235
'RENAME'=236
'REPAIR'=237
'REPEATABLE'=238
'REPLACE'=239
'RESET'=240
'RESPECT'=241
'RESTRICT'=242
'REVOKE'=243
'RIGHT'=244
'RLIKE'=245
'REGEXP'=246
'ROLE'=247
'ROLES'=248
'ROLLBACK'=249
'ROLLUP'=250
'ROW'=251
'ROWS'=252
'SECOND'=253
'SECONDS'=254
'SCHEMA'=255
'SCHEMAS'=256
'SELECT'=257
'SEMI'=258
'SEPARATED'=259
'SERDE'=260
'SERDEPROPERTIES'=261
'SESSION_USER'=262
'SET'=263
'MINUS'=264
'SETS'=265
'SHORT'=266
'SHOW'=267
'SINGLE'=268
'SKEWED'=269
'SMALLINT'=270
'SOME'=271
'SORT'=272
'SORTED'=273
'SOURCE'=274
'START'=275
'STATISTICS'=276
'STORED'=277
'STRATIFY'=278
'STRING'=279
'STRUCT'=280
'SUBSTR'=281
'SUBSTRING'=282
'SYNC'=283
'SYSTEM'=284
'SYSTEM_TIME'=285
'SYSTEM_VERSION'=286
'TABLE'=287
'TABLES'=288
'TABLESAMPLE'=289
'TARGET'=290
'TBLPROPERTIES'=291
'TEMPORARY'=292
'TERMINATED'=293
'THEN'=294
'TIME'=295
'TIMEDIFF'=296
'TIMESTAMP'=297
'TIMESTAMP_LTZ'=298
'TIMESTAMP_NTZ'=299
'TIMESTAMPADD'=300
'TIMESTAMPDIFF'=301
'TINYINT'=302
'TO'=303
'TOUCH'=304
'TRAILING'=305
'TRANSACTION'=306
'TRANSACTIONS'=307
'TRANSFORM'=308
'TRIM'=309
'TRUE'=310
'TRUNCATE'=311
'TRY_CAST'=312
'TYPE'=313
'UNARCHIVE'=314
'UNBOUNDED'=315
'UNCACHE'=316
'UNION'=317
'UNIQUE'=318
'UNKNOWN'=319
'UNLOCK'=320
'UNPIVOT'=321
'UNSET'=322
'UPDATE'=323
'USE'=324
'USER'=325
'USING'=326
'VALUES'=327
'VARCHAR'=328
'VAR'=329
'VARIABLE'=330
'VERSION'=331
'VIEW'=332
'VIEWS'=333
'VOID'=334
'WEEK'=335
'WEEKS'=336
'WHEN'=337
'WHERE'=338
'WINDOW'=339
'WITH'=340
'WITHIN'=341
'YEAR'=342
'YEARS'=343
'ZONE'=344
'<=>'=346
'<>'=347
'!='=348
'<'=349
'>'=351
'!'=353
'+'=354
'-'=355
'*'=356
'/'=357
'%'=358
'~'=359
'&'=360
'|'=361
'||'=362
'^'=363
':'=364
'->'=365
'=>'=366
'/*+'=367
'*/'=368
'?'=369

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/spark/SparkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/spark/SparkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
@ -48,6 +48,9 @@ import { TableNameCreateContext } from "./SparkSqlParser";
import { TableNameContext } from "./SparkSqlParser";
import { ViewNameCreateContext } from "./SparkSqlParser";
import { ViewNameContext } from "./SparkSqlParser";
import { ColumnNameContext } from "./SparkSqlParser";
import { ColumnNameSeqContext } from "./SparkSqlParser";
import { ColumnNameCreateContext } from "./SparkSqlParser";
import { IdentifierReferenceContext } from "./SparkSqlParser";
import { QueryOrganizationContext } from "./SparkSqlParser";
import { MultiInsertQueryBodyContext } from "./SparkSqlParser";
@ -159,8 +162,10 @@ import { UnitInUnitToUnitContext } from "./SparkSqlParser";
import { ColPositionContext } from "./SparkSqlParser";
import { TypeContext } from "./SparkSqlParser";
import { DataTypeContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionListContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionSeqForAddContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionForAddContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionSeqForReplaceContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionForReplaceContext } from "./SparkSqlParser";
import { ColDefinitionDescriptorWithPositionContext } from "./SparkSqlParser";
import { DefaultExpressionContext } from "./SparkSqlParser";
import { VariableDefaultExpressionContext } from "./SparkSqlParser";
@ -698,6 +703,39 @@ export interface SparkSqlParserListener extends ParseTreeListener {
*/
exitViewName?: (ctx: ViewNameContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.columnName`.
* @param ctx the parse tree
*/
enterColumnName?: (ctx: ColumnNameContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.columnName`.
* @param ctx the parse tree
*/
exitColumnName?: (ctx: ColumnNameContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.columnNameSeq`.
* @param ctx the parse tree
*/
enterColumnNameSeq?: (ctx: ColumnNameSeqContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.columnNameSeq`.
* @param ctx the parse tree
*/
exitColumnNameSeq?: (ctx: ColumnNameSeqContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
enterColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
exitColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.identifierReference`.
* @param ctx the parse tree
@ -1920,26 +1958,48 @@ export interface SparkSqlParserListener extends ParseTreeListener {
exitDataType?: (ctx: DataTypeContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionList`.
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForAdd`.
* @param ctx the parse tree
*/
enterQualifiedColTypeWithPositionList?: (ctx: QualifiedColTypeWithPositionListContext) => void;
enterQualifiedColTypeWithPositionSeqForAdd?: (ctx: QualifiedColTypeWithPositionSeqForAddContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionList`.
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForAdd`.
* @param ctx the parse tree
*/
exitQualifiedColTypeWithPositionList?: (ctx: QualifiedColTypeWithPositionListContext) => void;
exitQualifiedColTypeWithPositionSeqForAdd?: (ctx: QualifiedColTypeWithPositionSeqForAddContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPosition`.
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForAdd`.
* @param ctx the parse tree
*/
enterQualifiedColTypeWithPosition?: (ctx: QualifiedColTypeWithPositionContext) => void;
enterQualifiedColTypeWithPositionForAdd?: (ctx: QualifiedColTypeWithPositionForAddContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPosition`.
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForAdd`.
* @param ctx the parse tree
*/
exitQualifiedColTypeWithPosition?: (ctx: QualifiedColTypeWithPositionContext) => void;
exitQualifiedColTypeWithPositionForAdd?: (ctx: QualifiedColTypeWithPositionForAddContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForReplace`.
* @param ctx the parse tree
*/
enterQualifiedColTypeWithPositionSeqForReplace?: (ctx: QualifiedColTypeWithPositionSeqForReplaceContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForReplace`.
* @param ctx the parse tree
*/
exitQualifiedColTypeWithPositionSeqForReplace?: (ctx: QualifiedColTypeWithPositionSeqForReplaceContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForReplace`.
* @param ctx the parse tree
*/
enterQualifiedColTypeWithPositionForReplace?: (ctx: QualifiedColTypeWithPositionForReplaceContext) => void;
/**
* Exit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForReplace`.
* @param ctx the parse tree
*/
exitQualifiedColTypeWithPositionForReplace?: (ctx: QualifiedColTypeWithPositionForReplaceContext) => void;
/**
* Enter a parse tree produced by `SparkSqlParser.colDefinitionDescriptorWithPosition`.

View File

@ -1,4 +1,4 @@
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/spark/SparkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/spark/SparkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
@ -48,6 +48,9 @@ import { TableNameCreateContext } from "./SparkSqlParser";
import { TableNameContext } from "./SparkSqlParser";
import { ViewNameCreateContext } from "./SparkSqlParser";
import { ViewNameContext } from "./SparkSqlParser";
import { ColumnNameContext } from "./SparkSqlParser";
import { ColumnNameSeqContext } from "./SparkSqlParser";
import { ColumnNameCreateContext } from "./SparkSqlParser";
import { IdentifierReferenceContext } from "./SparkSqlParser";
import { QueryOrganizationContext } from "./SparkSqlParser";
import { MultiInsertQueryBodyContext } from "./SparkSqlParser";
@ -159,8 +162,10 @@ import { UnitInUnitToUnitContext } from "./SparkSqlParser";
import { ColPositionContext } from "./SparkSqlParser";
import { TypeContext } from "./SparkSqlParser";
import { DataTypeContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionListContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionSeqForAddContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionForAddContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionSeqForReplaceContext } from "./SparkSqlParser";
import { QualifiedColTypeWithPositionForReplaceContext } from "./SparkSqlParser";
import { ColDefinitionDescriptorWithPositionContext } from "./SparkSqlParser";
import { DefaultExpressionContext } from "./SparkSqlParser";
import { VariableDefaultExpressionContext } from "./SparkSqlParser";
@ -521,6 +526,27 @@ export interface SparkSqlParserVisitor<Result> extends ParseTreeVisitor<Result>
*/
visitViewName?: (ctx: ViewNameContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.columnName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnName?: (ctx: ColumnNameContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.columnNameSeq`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnNameSeq?: (ctx: ColumnNameSeqContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.columnNameCreate`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnNameCreate?: (ctx: ColumnNameCreateContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.identifierReference`.
* @param ctx the parse tree
@ -1299,18 +1325,32 @@ export interface SparkSqlParserVisitor<Result> extends ParseTreeVisitor<Result>
visitDataType?: (ctx: DataTypeContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionList`.
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForAdd`.
* @param ctx the parse tree
* @return the visitor result
*/
visitQualifiedColTypeWithPositionList?: (ctx: QualifiedColTypeWithPositionListContext) => Result;
visitQualifiedColTypeWithPositionSeqForAdd?: (ctx: QualifiedColTypeWithPositionSeqForAddContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPosition`.
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForAdd`.
* @param ctx the parse tree
* @return the visitor result
*/
visitQualifiedColTypeWithPosition?: (ctx: QualifiedColTypeWithPositionContext) => Result;
visitQualifiedColTypeWithPositionForAdd?: (ctx: QualifiedColTypeWithPositionForAddContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionSeqForReplace`.
* @param ctx the parse tree
* @return the visitor result
*/
visitQualifiedColTypeWithPositionSeqForReplace?: (ctx: QualifiedColTypeWithPositionSeqForReplaceContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.qualifiedColTypeWithPositionForReplace`.
* @param ctx the parse tree
* @return the visitor result
*/
visitQualifiedColTypeWithPositionForReplace?: (ctx: QualifiedColTypeWithPositionForReplaceContext) => Result;
/**
* Visit a parse tree produced by `SparkSqlParser.colDefinitionDescriptorWithPosition`.

File diff suppressed because one or more lines are too long

View File

@ -228,6 +228,7 @@ import { QuerySpecificationContext } from "./TrinoSqlParser";
import { GroupByContext } from "./TrinoSqlParser";
import { GroupingElementContext } from "./TrinoSqlParser";
import { GroupingSetContext } from "./TrinoSqlParser";
import { GroupingTermContext } from "./TrinoSqlParser";
import { WindowDefinitionContext } from "./TrinoSqlParser";
import { WindowSpecificationContext } from "./TrinoSqlParser";
import { NamedQueryContext } from "./TrinoSqlParser";
@ -246,6 +247,8 @@ import { SkipToContext } from "./TrinoSqlParser";
import { SubsetDefinitionContext } from "./TrinoSqlParser";
import { VariableDefinitionContext } from "./TrinoSqlParser";
import { AliasedRelationContext } from "./TrinoSqlParser";
import { ColumnListCreateContext } from "./TrinoSqlParser";
import { ColumnListContext } from "./TrinoSqlParser";
import { ColumnAliasesContext } from "./TrinoSqlParser";
import { RelationPrimaryContext } from "./TrinoSqlParser";
import { ExpressionContext } from "./TrinoSqlParser";
@ -297,6 +300,8 @@ import { SchemaPathContext } from "./TrinoSqlParser";
import { CatalogNameContext } from "./TrinoSqlParser";
import { CatalogNameCreateContext } from "./TrinoSqlParser";
import { FunctionNameContext } from "./TrinoSqlParser";
import { ColumnNameContext } from "./TrinoSqlParser";
import { ColumnNameCreateContext } from "./TrinoSqlParser";
import { QualifiedNameContext } from "./TrinoSqlParser";
import { GrantorContext } from "./TrinoSqlParser";
import { PrincipalContext } from "./TrinoSqlParser";
@ -3182,6 +3187,17 @@ export interface TrinoSqlListener extends ParseTreeListener {
*/
exitGroupingSet?: (ctx: GroupingSetContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.groupingTerm`.
* @param ctx the parse tree
*/
enterGroupingTerm?: (ctx: GroupingTermContext) => void;
/**
* Exit a parse tree produced by `TrinoSqlParser.groupingTerm`.
* @param ctx the parse tree
*/
exitGroupingTerm?: (ctx: GroupingTermContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.windowDefinition`.
* @param ctx the parse tree
@ -3380,6 +3396,28 @@ export interface TrinoSqlListener extends ParseTreeListener {
*/
exitAliasedRelation?: (ctx: AliasedRelationContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.columnListCreate`.
* @param ctx the parse tree
*/
enterColumnListCreate?: (ctx: ColumnListCreateContext) => void;
/**
* Exit a parse tree produced by `TrinoSqlParser.columnListCreate`.
* @param ctx the parse tree
*/
exitColumnListCreate?: (ctx: ColumnListCreateContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.columnList`.
* @param ctx the parse tree
*/
enterColumnList?: (ctx: ColumnListContext) => void;
/**
* Exit a parse tree produced by `TrinoSqlParser.columnList`.
* @param ctx the parse tree
*/
exitColumnList?: (ctx: ColumnListContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.columnAliases`.
* @param ctx the parse tree
@ -3941,6 +3979,28 @@ export interface TrinoSqlListener extends ParseTreeListener {
*/
exitFunctionName?: (ctx: FunctionNameContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.columnName`.
* @param ctx the parse tree
*/
enterColumnName?: (ctx: ColumnNameContext) => void;
/**
* Exit a parse tree produced by `TrinoSqlParser.columnName`.
* @param ctx the parse tree
*/
exitColumnName?: (ctx: ColumnNameContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
enterColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Exit a parse tree produced by `TrinoSqlParser.columnNameCreate`.
* @param ctx the parse tree
*/
exitColumnNameCreate?: (ctx: ColumnNameCreateContext) => void;
/**
* Enter a parse tree produced by `TrinoSqlParser.qualifiedName`.
* @param ctx the parse tree

File diff suppressed because one or more lines are too long

View File

@ -228,6 +228,7 @@ import { QuerySpecificationContext } from "./TrinoSqlParser";
import { GroupByContext } from "./TrinoSqlParser";
import { GroupingElementContext } from "./TrinoSqlParser";
import { GroupingSetContext } from "./TrinoSqlParser";
import { GroupingTermContext } from "./TrinoSqlParser";
import { WindowDefinitionContext } from "./TrinoSqlParser";
import { WindowSpecificationContext } from "./TrinoSqlParser";
import { NamedQueryContext } from "./TrinoSqlParser";
@ -246,6 +247,8 @@ import { SkipToContext } from "./TrinoSqlParser";
import { SubsetDefinitionContext } from "./TrinoSqlParser";
import { VariableDefinitionContext } from "./TrinoSqlParser";
import { AliasedRelationContext } from "./TrinoSqlParser";
import { ColumnListCreateContext } from "./TrinoSqlParser";
import { ColumnListContext } from "./TrinoSqlParser";
import { ColumnAliasesContext } from "./TrinoSqlParser";
import { RelationPrimaryContext } from "./TrinoSqlParser";
import { ExpressionContext } from "./TrinoSqlParser";
@ -297,6 +300,8 @@ import { SchemaPathContext } from "./TrinoSqlParser";
import { CatalogNameContext } from "./TrinoSqlParser";
import { CatalogNameCreateContext } from "./TrinoSqlParser";
import { FunctionNameContext } from "./TrinoSqlParser";
import { ColumnNameContext } from "./TrinoSqlParser";
import { ColumnNameCreateContext } from "./TrinoSqlParser";
import { QualifiedNameContext } from "./TrinoSqlParser";
import { GrantorContext } from "./TrinoSqlParser";
import { PrincipalContext } from "./TrinoSqlParser";
@ -2087,6 +2092,13 @@ export interface TrinoSqlVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitGroupingSet?: (ctx: GroupingSetContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.groupingTerm`.
* @param ctx the parse tree
* @return the visitor result
*/
visitGroupingTerm?: (ctx: GroupingTermContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.windowDefinition`.
* @param ctx the parse tree
@ -2213,6 +2225,20 @@ export interface TrinoSqlVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitAliasedRelation?: (ctx: AliasedRelationContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.columnListCreate`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnListCreate?: (ctx: ColumnListCreateContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.columnList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnList?: (ctx: ColumnListContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.columnAliases`.
* @param ctx the parse tree
@ -2570,6 +2596,20 @@ export interface TrinoSqlVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitFunctionName?: (ctx: FunctionNameContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.columnName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnName?: (ctx: ColumnNameContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.columnNameCreate`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnNameCreate?: (ctx: ColumnNameCreateContext) => Result;
/**
* Visit a parse tree produced by `TrinoSqlParser.qualifiedName`.
* @param ctx the parse tree

View File

@ -32,6 +32,8 @@ export default class FlinkSQL extends BasicParser<FlinkSqlLexer, ProgramContext,
FlinkSqlParser.RULE_viewPathCreate, // viewName that will be created
FlinkSqlParser.RULE_functionName, // functionName
FlinkSqlParser.RULE_functionNameCreate, // functionName that will be created
FlinkSqlParser.RULE_columnName,
FlinkSqlParser.RULE_columnNameCreate,
]);
protected get splitListener() {
@ -93,6 +95,14 @@ export default class FlinkSQL extends BasicParser<FlinkSqlLexer, ProgramContext,
syntaxContextType = SyntaxContextType.FUNCTION_CREATE;
break;
}
case FlinkSqlParser.RULE_columnName: {
syntaxContextType = SyntaxContextType.COLUMN;
break;
}
case FlinkSqlParser.RULE_columnNameCreate: {
syntaxContextType = SyntaxContextType.COLUMN_CREATE;
break;
}
default:
break;
}

View File

@ -26,6 +26,8 @@ export default class HiveSQL extends BasicParser<HiveSqlLexer, ProgramContext, H
HiveSqlParser.RULE_functionNameForDDL, // function name
HiveSqlParser.RULE_functionNameForInvoke, // function name
HiveSqlParser.RULE_functionNameCreate, // function name that will be created
HiveSqlParser.RULE_columnName,
HiveSqlParser.RULE_columnNameCreate,
]);
protected get splitListener() {
@ -83,6 +85,14 @@ export default class HiveSQL extends BasicParser<HiveSqlLexer, ProgramContext, H
syntaxContextType = SyntaxContextType.FUNCTION_CREATE;
break;
}
case HiveSqlParser.RULE_columnName: {
syntaxContextType = SyntaxContextType.COLUMN;
break;
}
case HiveSqlParser.RULE_columnNameCreate: {
syntaxContextType = SyntaxContextType.COLUMN_CREATE;
break;
}
default:
break;
}

View File

@ -30,6 +30,8 @@ export default class SparkSQL extends BasicParser<SparkSqlLexer, ProgramContext,
SparkSqlParser.RULE_viewNameCreate,
SparkSqlParser.RULE_functionName,
SparkSqlParser.RULE_functionNameCreate,
SparkSqlParser.RULE_columnName,
SparkSqlParser.RULE_columnNameCreate,
]);
protected get splitListener() {
@ -87,6 +89,14 @@ export default class SparkSQL extends BasicParser<SparkSqlLexer, ProgramContext,
syntaxContextType = SyntaxContextType.FUNCTION_CREATE;
break;
}
case SparkSqlParser.RULE_columnName: {
syntaxContextType = SyntaxContextType.COLUMN;
break;
}
case SparkSqlParser.RULE_columnNameCreate: {
syntaxContextType = SyntaxContextType.COLUMN_CREATE;
break;
}
default:
break;
}

View File

@ -31,6 +31,8 @@ export default class TrinoSQL extends BasicParser<TrinoSqlLexer, ProgramContext,
TrinoSqlParser.RULE_viewName,
TrinoSqlParser.RULE_viewNameCreate,
TrinoSqlParser.RULE_functionName,
TrinoSqlParser.RULE_columnName,
TrinoSqlParser.RULE_columnNameCreate,
]);
protected processCandidates(
@ -84,6 +86,14 @@ export default class TrinoSQL extends BasicParser<TrinoSqlLexer, ProgramContext,
syntaxContextType = SyntaxContextType.FUNCTION;
break;
}
case TrinoSqlParser.RULE_columnNameCreate: {
syntaxContextType = SyntaxContextType.COLUMN_CREATE;
break;
}
case TrinoSqlParser.RULE_columnName: {
syntaxContextType = SyntaxContextType.COLUMN;
break;
}
default:
break;
}

View File

@ -1,25 +1,41 @@
DROP CATALOG cat;
;
SELECT * FROM cat. ;
;
CREATE TABLE cat.db ;
;
SHOW TABLES FROM cat;
;
ALTER DATABASE cat.;
;
DROP VIEW v;
;
SELECT * FROM ;
;
CREATE VIEW cv;
;
SELECT name, calculate_age(birthdate) AS age FROM students;
;
CREATE FUNCTION fnc;
;
SHOW COLUMNS FROM vie;
;
SHOW CREATE TABLE tb1;
SHOW CREATE VIEW v1;
SELECT col ;
SELECT col FROM tb1;
SELECT col, FROM tb1;
SELECT * FROM tb ORDER BY ;
SELECT * FROM tb GROUP BY tb. ;
INSERT INTO tb (col, tb.c );
CREATE TABLE yourTable (ts TIMESTAMP(3), WATERMARK FOR );
CREATE TABLE newTable ( );

View File

@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import FlinkSQL from '../../../../src/parser/flinksql';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'syntaxSuggestion.sql'),
@ -37,7 +38,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 1,
column: 17,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.CATALOG
);
@ -51,7 +55,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 3,
column: 19,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -65,7 +72,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 5,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE_CREATE
);
@ -79,7 +89,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 7,
column: 21,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
@ -93,7 +106,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 9,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
@ -107,7 +123,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 11,
column: 12,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -121,7 +140,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 13,
column: 15,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -135,7 +157,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 15,
column: 15,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW_CREATE
);
@ -149,7 +174,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 17,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION
);
@ -163,7 +191,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 19,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION_CREATE
);
@ -177,7 +208,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 21,
column: 22,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -191,7 +225,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 23,
column: 22,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -205,7 +242,10 @@ describe('Flink SQL Syntax Suggestion', () => {
lineNumber: 25,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -213,4 +253,140 @@ describe('Flink SQL Syntax Suggestion', () => {
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['v1']);
});
test('Select columns', () => {
const pos: CaretPosition = {
lineNumber: 27,
column: 11,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col']);
});
test('Select columns from table', () => {
const pos: CaretPosition = {
lineNumber: 29,
column: 11,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col']);
});
test('Select multiple columns from table', () => {
const pos: CaretPosition = {
lineNumber: 31,
column: 13,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select order by column', () => {
const pos: CaretPosition = {
lineNumber: 33,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select group by column', () => {
const pos: CaretPosition = {
lineNumber: 35,
column: 30,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb', '.']);
});
test('Insert into spec columns', () => {
const pos: CaretPosition = {
lineNumber: 37,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb', '.', 'c']);
});
test('Watermark for', () => {
const pos: CaretPosition = {
lineNumber: 39,
column: 56,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Create table new columns', () => {
const pos: CaretPosition = {
lineNumber: 41,
column: 25,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
});

View File

@ -17,3 +17,19 @@ SELECT name, calculate_age(birthday) AS age FROM students;
CREATE DATABASE db;
DROP SCHEMA IF EXISTS sch;
SELECT co;
SELECT ;
INSERT INTO tb ( );
SELECT * FROM tb1 ORDER BY tb.c;
CREATE TABLE newtb ( id INT, n );
MERGE INTO tablename USING tablename2 ON (tablename.id = tablename2.id) WHEN MATCHED THEN UPDATE SET tablename.col ;
ALTER TABLE tbl CHANGE COLUMN ;
ALTER TABLE tbl CHANGE COLUMN tbl.oldcol new ;

View File

@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import HiveSQL from '../../../../src/parser/hive';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'syntaxSuggestion.sql'),
@ -22,7 +23,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 1,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -36,7 +40,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 3,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -50,7 +57,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 5,
column: 17,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE_CREATE
);
@ -64,7 +74,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 7,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -78,7 +91,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 9,
column: 28,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW_CREATE
);
@ -92,7 +108,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 11,
column: 15,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -106,7 +125,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 13,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION_CREATE
);
@ -120,7 +142,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 15,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION
);
@ -134,7 +159,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 17,
column: 19,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE_CREATE
);
@ -148,7 +176,10 @@ describe('Hive SQL Syntax Suggestion', () => {
lineNumber: 19,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
@ -156,4 +187,127 @@ describe('Hive SQL Syntax Suggestion', () => {
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['sch']);
});
test('Select column with no fill-in', () => {
const pos: CaretPosition = {
lineNumber: 23,
column: 8,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Insert into spec col', () => {
const pos: CaretPosition = {
lineNumber: 25,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select order by', () => {
const pos: CaretPosition = {
lineNumber: 27,
column: 32,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb', '.', 'c']);
});
test('Create Table new column', () => {
const pos: CaretPosition = {
lineNumber: 29,
column: 31,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['n']);
});
test('Merge into when matched', () => {
const pos: CaretPosition = {
lineNumber: 31,
column: 115,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([
'tablename',
'.',
'col',
]);
});
test('Alter Table rename col', () => {
const pos: CaretPosition = {
lineNumber: 33,
column: 31,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Alter Table rename col to', () => {
const pos: CaretPosition = {
lineNumber: 35,
column: 45,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['new']);
});
});

View File

@ -17,3 +17,33 @@ SELECT name, calculate_age(birthday) AS age FROM students;
CREATE DATABASE db;
DROP SCHEMA IF EXISTS sch;
ANALYZE TABLE students COMPUTE STATISTICS FOR COLUMNS name, co ;
ALTER TABLE StudentInfo ADD COLUMNS (LastName string, );
ALTER TABLE StudentInfo RENAME COLUMN ;
ALTER TABLE StudentInfo RENAME COLUMN name TO t;
ALTER TABLE StudentInfo DROP COLUMNS (LastName, );
ALTER TABLE StudentInfo CHANGE FirstName;
INSERT INTO students ( );
INSERT INTO students ( id, n );
SELECT ;
SELECT id, n;
SELECT FROM tbl;
SELECT id, n FROM tbl;
SELECT id, n FROM tbl GROUP BY ;
SELECT id, n FROM tbl ORDER BY name, i ;
SELECT id FROM tb1 GROUP BY ROLLUP( );

View File

@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import SparkSQL from '../../../../src/parser/spark';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'syntaxSuggestion.sql'),
@ -22,7 +23,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 1,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -36,7 +40,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 3,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -50,7 +57,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 5,
column: 17,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE_CREATE
);
@ -64,7 +74,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 7,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
@ -78,7 +91,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 9,
column: 28,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW_CREATE
);
@ -92,7 +108,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 11,
column: 15,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
@ -106,7 +125,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 13,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION_CREATE
);
@ -120,7 +142,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 15,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION
);
@ -134,7 +159,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 17,
column: 19,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE_CREATE
);
@ -148,7 +176,10 @@ describe('Spark SQL Syntax Suggestion', () => {
lineNumber: 19,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
@ -156,4 +187,259 @@ describe('Spark SQL Syntax Suggestion', () => {
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['sch']);
});
test('ANALYZE table for columns', () => {
const pos: CaretPosition = {
lineNumber: 21,
column: 63,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['co']);
});
test('Alter table add columns', () => {
const pos: CaretPosition = {
lineNumber: 23,
column: 55,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Alter table rename columns', () => {
const pos: CaretPosition = {
lineNumber: 25,
column: 39,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Alter table rename columns to', () => {
const pos: CaretPosition = {
lineNumber: 27,
column: 48,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['t']);
});
test('Alter table drop columns', () => {
const pos: CaretPosition = {
lineNumber: 29,
column: 49,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Alter table change columns', () => {
const pos: CaretPosition = {
lineNumber: 31,
column: 41,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['FirstName']);
});
test('Insert into table spec columns', () => {
const pos: CaretPosition = {
lineNumber: 33,
column: 24,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Insert into table spec columns2', () => {
const pos: CaretPosition = {
lineNumber: 35,
column: 29,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['n']);
});
test('Select columns case empty', () => {
const pos: CaretPosition = {
lineNumber: 37,
column: 8,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select columns case seq', () => {
const pos: CaretPosition = {
lineNumber: 39,
column: 13,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['n']);
});
test('Select columns from table case empty', () => {
const pos: CaretPosition = {
lineNumber: 41,
column: 8,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select columns from table case seq', () => {
const pos: CaretPosition = {
lineNumber: 43,
column: 13,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['n']);
});
test('Select group by', () => {
const pos: CaretPosition = {
lineNumber: 45,
column: 32,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select group by', () => {
const pos: CaretPosition = {
lineNumber: 47,
column: 39,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['i']);
});
test('Select group by rollup', () => {
const pos: CaretPosition = {
lineNumber: 49,
column: 37,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
});

View File

@ -17,3 +17,21 @@ CREATE SCHEMA db ;
DROP SCHEMA IF EXISTS sch;
SHOW COLUMNS FROM tb ;
COMMENT ON COLUMN tb.;
ALTER TABLE tb RENAME COLUMN ;
ALTER TABLE tb RENAME COLUMN ids TO ;
ALTER TABLE users DROP COLUMN ;
ALTER TABLE users ADD COLUMN zi ;
SHOW COMMENT ON COLUMN tb.c ;
INSERT INTO tb (id, );
SELECT * FROM tb ORDER BY ;
SELECT * FROM tb GROUP BY ;

View File

@ -198,4 +198,161 @@ describe('Trino SQL Syntax Suggestion', () => {
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb']);
});
test('Comment on column', () => {
const pos: CaretPosition = {
lineNumber: 21,
column: 22,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb', '.']);
});
test('RENAME column', () => {
const pos: CaretPosition = {
lineNumber: 23,
column: 30,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('RENAME column to', () => {
const pos: CaretPosition = {
lineNumber: 25,
column: 37,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Drop column', () => {
const pos: CaretPosition = {
lineNumber: 27,
column: 31,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Alter table add column', () => {
const pos: CaretPosition = {
lineNumber: 29,
column: 32,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['zi']);
});
test('Show comment on column', () => {
const pos: CaretPosition = {
lineNumber: 31,
column: 28,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['tb', '.', 'c']);
});
test('Insert into spec column', () => {
const pos: CaretPosition = {
lineNumber: 33,
column: 21,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select order by', () => {
const pos: CaretPosition = {
lineNumber: 35,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
test('Select group by', () => {
const pos: CaretPosition = {
lineNumber: 37,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
});
});