feat: collect entity (#265)
* feat: add text and word utils * feat: add entity collector class * refactor: rename SyntaxContextType to EntityContextType * refactor: improve EntityCollector * feat: improve mysql parser grammar * feat: add mysql entity collector * test: mysql entity collector tests * feat: remove useless method * feat: improve spark grammar file * feat: add spark entity collector * test: spark entity collector unit tests * feat: remove useless code * feat: add queryStatement label * feat: add crateDatabaseStmt * feat: add trino entity collector * feat: rename trinosql to trino * test: trino collect entity unit tests * test: fix spark test * feat(impala): support impale entity collector (#256) * Feat/collect entity hive (#263) * feat(hive): support hive collect entity * feat(hive): update tableAllColumns * feat: replace antlr4ts with antlr4ng * feat(pgsql): pgsql collect entity (#268) * feat(pgsql): pgsql collect entity * feat(pgsql): optimize some name --------- Co-authored-by: zhaoge <> * feat: get word text by token.text * feat: supprt collect db/function and add splitListener (#270) * feat: supprt collect db/function and add splitListner * feat: remove SplitListener interface in baseParser to use SplitListener in root * fix(mysql): fix show create xxx not celloct as createXXXEntity type * test: fix pgsql unit tests * Feat/error recover predicate (#274) * feat: optimize pgsql grammar * feat: add sql parser base * feat: apply SQLParserBase * feat: add geAllEntities method * test: test collect table when missing column * feat: compose collect and suggestion (#276) * feat: mark stmt which contain caret * test: correct name of getAllEntities * test: remove misscolumn unit tests * test: add suggestionWithEntity tests * feat: flink collect entity (#277) * feat: improve flink sql parser * feat: support flink entity collector * test: flink entity collect unit test * feat: move combine entities to parent class --------- Co-authored-by: 霜序 <976060700@qq.com> Co-authored-by: XCynthia <942884029@qq.com>
This commit is contained in:
@ -7,6 +7,11 @@ parser grammar FlinkSqlParser;
|
||||
options {
|
||||
tokenVocab=FlinkSqlLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
program
|
||||
@ -180,7 +185,7 @@ columnNameCreate
|
||||
|
||||
columnName
|
||||
: uid
|
||||
| expression
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
columnNameList
|
||||
@ -289,7 +294,6 @@ transformList
|
||||
|
||||
transform
|
||||
: columnName # identityTransform
|
||||
| qualifiedName # columnTransform
|
||||
| LR_BRACKET transformArgument (COMMA transformArgument)* RR_BRACKET # applyTransform
|
||||
;
|
||||
|
||||
@ -484,6 +488,7 @@ selectClause
|
||||
projectItemDefinition
|
||||
: overWindowItem
|
||||
| columnName (KW_AS? expression)?
|
||||
| expression (KW_AS? columnName)?
|
||||
;
|
||||
|
||||
overWindowItem
|
||||
@ -583,6 +588,7 @@ groupItemDefinition
|
||||
| LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||
| groupingSetsNotaionName LR_BRACKET expression (COMMA expression)* RR_BRACKET
|
||||
| groupingSets LR_BRACKET groupItemDefinition (COMMA groupItemDefinition)* RR_BRACKET
|
||||
| expression
|
||||
;
|
||||
|
||||
groupingSets
|
||||
|
@ -1,23 +1,21 @@
|
||||
/**
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
|
||||
See the NOTICE file distributed with this work for additional information regarding copyright
|
||||
ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License. You may obtain a copy of the
|
||||
License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing permissions and limitations under the
|
||||
License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is an adaptation of antlr/grammars-v4's sql/hive/v4/HiveParser.g4 grammar.
|
||||
* Reference: https://github.com/antlr/grammars-v4/blob/master/sql/hive/v4/HiveParser.g4
|
||||
* This file is an adaptation of antlr/grammars-v4's sql/hive/v4/HiveParser.g4 grammar. Reference:
|
||||
* https://github.com/antlr/grammars-v4/blob/master/sql/hive/v4/HiveParser.g4
|
||||
*/
|
||||
|
||||
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
||||
@ -30,6 +28,11 @@ options
|
||||
{
|
||||
tokenVocab=HiveSqlLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
program
|
||||
@ -804,6 +807,7 @@ columnNameList
|
||||
|
||||
columnName
|
||||
: id_ (DOT id_)*
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
columnNameCreate
|
||||
@ -1096,7 +1100,10 @@ fromStatement
|
||||
;
|
||||
|
||||
singleFromStatement
|
||||
: fromClause b+=body+
|
||||
: fromClause insertClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause?
|
||||
clusterByClause? distributeByClause? sortByClause? limitClause? # fromInsertStmt
|
||||
| fromClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause? clusterByClause?
|
||||
distributeByClause? sortByClause? limitClause? # fromSelectStmt
|
||||
;
|
||||
|
||||
/*
|
||||
@ -1106,8 +1113,8 @@ The valuesClause rule below ensures that the parse tree for
|
||||
very similar to the tree for "insert into table FOO select a,b from BAR".
|
||||
*/
|
||||
regularBody
|
||||
: i=insertClause s=selectStatement
|
||||
| selectStatement
|
||||
: i=insertClause s=selectStatement # insertStmt
|
||||
| selectStatement # selectStmt
|
||||
;
|
||||
|
||||
atomSelectStatement
|
||||
@ -1128,13 +1135,6 @@ selectStatementWithCTE
|
||||
: w=withClause? selectStatement
|
||||
;
|
||||
|
||||
body
|
||||
: insertClause selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause? clusterByClause?
|
||||
distributeByClause? sortByClause? limitClause?
|
||||
| selectClause lateralView? whereClause? groupByClause? havingClause? window_clause? qualifyClause? orderByClause? clusterByClause?
|
||||
distributeByClause? sortByClause? limitClause?
|
||||
;
|
||||
|
||||
insertClause
|
||||
: KW_INSERT (
|
||||
KW_OVERWRITE destination ifNotExists?
|
||||
@ -1667,8 +1667,7 @@ dropDataConnectorStatement
|
||||
;
|
||||
|
||||
tableAllColumns
|
||||
: STAR
|
||||
| tableOrView DOT STAR
|
||||
: (id_ DOT)* STAR
|
||||
;
|
||||
|
||||
defaultValue
|
||||
@ -1866,6 +1865,7 @@ VALUES(1),(2) means 2 rows, 1 column each.
|
||||
VALUES(1,2),(3,4) means 2 rows, 2 columns each.
|
||||
VALUES(1,2,3) means 1 row, 3 columns
|
||||
*/
|
||||
|
||||
valuesClause
|
||||
: KW_VALUES valuesTableConstructor
|
||||
;
|
||||
|
@ -22,6 +22,11 @@ options
|
||||
{
|
||||
tokenVocab=ImpalaSqlLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
program
|
||||
@ -75,7 +80,7 @@ createStatement
|
||||
createTableSelect
|
||||
: KW_CREATE KW_EXTERNAL? KW_TABLE ifNotExists? tableNameCreate (
|
||||
LPAREN columnDefinition (COMMA columnDefinition)* (COMMA constraintSpecification)? RPAREN
|
||||
)? (KW_PARTITIONED KW_BY (partitionedBy | createColumnAliases))? createCommonItem (
|
||||
)? (KW_PARTITIONED KW_BY (columnAliases | partitionedBy))? createCommonItem (
|
||||
KW_AS queryStatement
|
||||
)?
|
||||
;
|
||||
@ -555,6 +560,7 @@ functionNamePath
|
||||
|
||||
columnNamePath
|
||||
: qualifiedName
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
tableOrViewPath
|
||||
@ -582,8 +588,8 @@ assignmentItem
|
||||
;
|
||||
|
||||
viewColumns
|
||||
: LPAREN columnNamePath (KW_COMMENT stringLiteral)? (
|
||||
COMMA identifier (KW_COMMENT stringLiteral)?
|
||||
: LPAREN columnNamePathCreate (KW_COMMENT stringLiteral)? (
|
||||
COMMA columnNamePathCreate (KW_COMMENT stringLiteral)?
|
||||
)* RPAREN
|
||||
;
|
||||
|
||||
@ -610,6 +616,10 @@ foreignKeySpecification
|
||||
)? (KW_RELY)?
|
||||
;
|
||||
|
||||
columnSpec
|
||||
: columnNamePath type (KW_COMMENT stringLiteral)?
|
||||
;
|
||||
|
||||
columnDefinition
|
||||
: columnNamePathCreate type (KW_COMMENT stringLiteral)?
|
||||
;
|
||||
@ -625,7 +635,7 @@ kuduColumnDefinition
|
||||
;
|
||||
|
||||
columnSpecWithKudu
|
||||
: columnNamePath type (KW_COMMENT stringLiteral)? (kuduAttributes kuduAttributes*?)?
|
||||
: columnSpec? (kuduAttributes kuduAttributes*?)?
|
||||
;
|
||||
|
||||
createColumnSpecWithKudu
|
||||
@ -712,7 +722,7 @@ properties
|
||||
;
|
||||
|
||||
partitionedBy
|
||||
: LPAREN columnDefinition (COMMA columnDefinition)*? RPAREN
|
||||
: LPAREN columnSpec (COMMA columnSpec)*? RPAREN
|
||||
;
|
||||
|
||||
sortedBy
|
||||
@ -835,10 +845,6 @@ columnAliases
|
||||
: LPAREN columnNamePath (COMMA columnNamePath)* RPAREN
|
||||
;
|
||||
|
||||
createColumnAliases
|
||||
: LPAREN columnNamePathCreate (COMMA columnNamePathCreate)* RPAREN
|
||||
;
|
||||
|
||||
relationPrimary
|
||||
: tableOrViewPath
|
||||
| KW_LATERAL? subQueryRelation
|
||||
|
@ -36,6 +36,11 @@ parser grammar MySqlParser;
|
||||
options {
|
||||
tokenVocab= MySqlLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
// Top Level Description
|
||||
@ -212,8 +217,8 @@ administrationStatement
|
||||
;
|
||||
|
||||
utilityStatement
|
||||
: simpleDescribeStatement
|
||||
| fullDescribeStatement
|
||||
: fullDescribeStatement
|
||||
| simpleDescribeStatement
|
||||
| analyzeDescribeStatement
|
||||
| helpStatement
|
||||
| useStatement
|
||||
@ -273,16 +278,16 @@ createServer
|
||||
;
|
||||
|
||||
createTable
|
||||
: KW_CREATE KW_TEMPORARY? KW_TABLE ifNotExists? tableNameCreate createDefinitions (
|
||||
: KW_CREATE KW_TEMPORARY? KW_TABLE ifNotExists? tb= tableNameCreate col=createDefinitions? (
|
||||
tableOption (','? tableOption)*
|
||||
)? partitionDefinitions? # copyCreateTable
|
||||
| KW_CREATE KW_TEMPORARY? KW_TABLE ifNotExists? tableNameCreate createDefinitions? (
|
||||
tableOption (','? tableOption)*
|
||||
)? partitionDefinitions? (KW_IGNORE | KW_REPLACE)? KW_AS? selectStatement # columnCreateTable
|
||||
)? partitionDefinitions? (KW_IGNORE | KW_REPLACE)? KW_AS? selectStatement # queryCreateTable
|
||||
| KW_CREATE KW_TEMPORARY? KW_TABLE ifNotExists? tableNameCreate (
|
||||
KW_LIKE tableName
|
||||
| '(' KW_LIKE tableName ')'
|
||||
) # queryCreateTable
|
||||
) # copyCreateTable
|
||||
| KW_CREATE KW_TEMPORARY? KW_TABLE ifNotExists? tableNameCreate createDefinitions (
|
||||
tableOption (','? tableOption)*
|
||||
)? partitionDefinitions? # columnCreateTable
|
||||
;
|
||||
|
||||
createTablespaceInnodb
|
||||
@ -326,7 +331,7 @@ commonTableExpressions
|
||||
createView
|
||||
: KW_CREATE orReplace? (KW_ALGORITHM '=' algType=(KW_UNDEFINED | KW_MERGE | KW_TEMPTABLE))? ownerStatement? (
|
||||
KW_SQL KW_SECURITY secContext=(KW_DEFINER | KW_INVOKER)
|
||||
)? KW_VIEW viewNameCreate ('(' columnNames ')')? KW_AS (
|
||||
)? KW_VIEW viewNameCreate ('(' columnNameCreate (',' columnNameCreate)* ')')? KW_AS (
|
||||
'(' withClause? selectStatement ')'
|
||||
| withClause? selectStatement (
|
||||
KW_WITH checkOption=(KW_CASCADED | KW_LOCAL)? KW_CHECK KW_OPTION
|
||||
@ -438,7 +443,7 @@ createDefinitions
|
||||
;
|
||||
|
||||
createDefinition
|
||||
: columnName columnDefinition
|
||||
: columnNameCreate columnDefinition
|
||||
| (KW_INDEX | KW_KEY) indexName? indexType? indexColumnNames indexOption*
|
||||
| (KW_FULLTEXT | KW_SPATIAL) (KW_INDEX | KW_KEY)? indexName? indexColumnNames indexOption*
|
||||
| constraintSymbol? KW_PRIMARY KW_KEY indexType? indexColumnNames indexOption*
|
||||
@ -2052,15 +2057,15 @@ showStatement
|
||||
| KW_SHOW KW_EXTENDED? KW_FULL? columnsFormat=(KW_COLUMNS | KW_FIELDS) tableFormat=(
|
||||
KW_FROM
|
||||
| KW_IN
|
||||
) tableName (schemaFormat=(KW_FROM | KW_IN) databaseName)? showFilter? # showColumns
|
||||
| KW_SHOW KW_CREATE (KW_DATABASE | KW_SCHEMA) ifNotExists? databaseNameCreate # showCreateDb
|
||||
| KW_SHOW KW_CREATE (KW_EVENT | KW_PROCEDURE | KW_TRIGGER) fullId # showCreateFullIdObject
|
||||
| KW_SHOW KW_CREATE KW_FUNCTION functionNameCreate # showCreateFunction
|
||||
| KW_SHOW KW_CREATE KW_VIEW viewNameCreate # showCreateView
|
||||
| KW_SHOW KW_CREATE KW_TABLE tableNameCreate # showCreateTable
|
||||
| KW_SHOW KW_CREATE KW_USER userName # showCreateUser
|
||||
| KW_SHOW KW_ENGINE engineName engineOption=(KW_STATUS | KW_MUTEX) # showEngine
|
||||
| KW_SHOW showGlobalInfoClause # showGlobalInfo
|
||||
) tableName (schemaFormat=(KW_FROM | KW_IN) databaseName)? showFilter? # showColumns
|
||||
| KW_SHOW KW_CREATE (KW_DATABASE | KW_SCHEMA) ifNotExists? databaseName # showCreateDb
|
||||
| KW_SHOW KW_CREATE (KW_EVENT | KW_PROCEDURE | KW_TRIGGER) fullId # showCreateFullIdObject
|
||||
| KW_SHOW KW_CREATE KW_FUNCTION functionName # showCreateFunction
|
||||
| KW_SHOW KW_CREATE KW_VIEW viewName # showCreateView
|
||||
| KW_SHOW KW_CREATE KW_TABLE tableName # showCreateTable
|
||||
| KW_SHOW KW_CREATE KW_USER userName # showCreateUser
|
||||
| KW_SHOW KW_ENGINE engineName engineOption=(KW_STATUS | KW_MUTEX) # showEngine
|
||||
| KW_SHOW showGlobalInfoClause # showGlobalInfo
|
||||
| KW_SHOW errorFormat=(KW_ERRORS | KW_WARNINGS) (
|
||||
KW_LIMIT (offset=decimalLiteral ',')? rowCount=decimalLiteral
|
||||
)? # showErrors
|
||||
@ -2396,6 +2401,7 @@ columnNames
|
||||
columnName
|
||||
: uid (dottedId dottedId?)?
|
||||
| .? dottedId dottedId?
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
tablespaceNameCreate
|
||||
@ -2751,12 +2757,12 @@ orReplace
|
||||
// Functions
|
||||
|
||||
functionCall
|
||||
: specificFunction # specificFunctionCall
|
||||
| aggregateWindowedFunction # aggregateFunctionCall
|
||||
| nonAggregateWindowedFunction # nonAggregateFunctionCall
|
||||
| scalarFunctionName '(' functionArgs? ')' # scalarFunctionCall
|
||||
| functionName '(' functionArgs? ')' # udfFunctionCall
|
||||
| passwordFunctionClause # passwordFunctionCall
|
||||
: specificFunction # specificFunctionCall
|
||||
| aggregateWindowedFunction # aggregateFunctionCall
|
||||
| nonAggregateWindowedFunction # nonAggregateFunctionCall
|
||||
| scalarFunctionName ('(' ')' | '(' functionArgs ')') # scalarFunctionCall
|
||||
| functionName ('(' ')' | '(' functionArgs ')') # udfFunctionCall
|
||||
| passwordFunctionClause # passwordFunctionCall
|
||||
;
|
||||
|
||||
specificFunction
|
||||
@ -2925,7 +2931,6 @@ functionArgs
|
||||
|
||||
functionArg
|
||||
: constant
|
||||
| columnName
|
||||
| functionCall
|
||||
| expression
|
||||
;
|
||||
@ -2941,22 +2946,23 @@ expression
|
||||
;
|
||||
|
||||
predicate
|
||||
: predicate KW_NOT? KW_IN '(' (selectStatement | expressions) ')' # inPredicate
|
||||
| predicate KW_IS nullNotnull # isNullPredicate
|
||||
| left=predicate comparisonOperator right=predicate # binaryComparisonPredicate
|
||||
| predicate comparisonOperator quantifier=(KW_ALL | KW_ANY | KW_SOME) '(' selectStatement ')' # subqueryComparisonPredicate
|
||||
| predicate KW_NOT? KW_BETWEEN predicate KW_AND predicate # betweenPredicate
|
||||
| predicate KW_SOUNDS KW_LIKE predicate # soundsLikePredicate
|
||||
| predicate KW_NOT? KW_LIKE predicate (KW_ESCAPE STRING_LITERAL)? # likePredicate
|
||||
| predicate KW_NOT? regex=(KW_REGEXP | KW_RLIKE) predicate # regexpPredicate
|
||||
| predicate KW_MEMBER KW_OF '(' predicate ')' # jsonMemberOfPredicate
|
||||
| expressionAtom # expressionAtomPredicate
|
||||
: predicate KW_NOT? KW_IN '(' (selectStatement | expressions) ')' # inPredicate
|
||||
| predicate KW_IS nullNotnull # isNullPredicate
|
||||
| predicate comparisonOperator (
|
||||
quantifier=(KW_ALL | KW_ANY | KW_SOME) '(' subQuery=selectStatement ')'
|
||||
| right=predicate
|
||||
) # binaryComparisonPredicate
|
||||
| predicate KW_NOT? KW_BETWEEN predicate KW_AND predicate # betweenPredicate
|
||||
| predicate KW_SOUNDS KW_LIKE predicate # soundsLikePredicate
|
||||
| predicate KW_NOT? KW_LIKE predicate (KW_ESCAPE STRING_LITERAL)? # likePredicate
|
||||
| predicate KW_NOT? regex=(KW_REGEXP | KW_RLIKE) predicate # regexpPredicate
|
||||
| predicate KW_MEMBER KW_OF '(' predicate ')' # jsonMemberOfPredicate
|
||||
| expressionAtom # expressionAtomPredicate
|
||||
;
|
||||
|
||||
// Add in ASTVisitor nullNotnull in constant
|
||||
expressionAtom
|
||||
: constant # constantExpressionAtom
|
||||
| columnName # columnNameExpressionAtom
|
||||
| functionCall # functionCallExpressionAtom
|
||||
| expressionAtom KW_COLLATE collationName # collateExpressionAtom
|
||||
| mysqlVariable # mysqlVariableExpressionAtom
|
||||
@ -2968,9 +2974,10 @@ expressionAtom
|
||||
| KW_EXISTS '(' selectStatement ')' # existsExpressionAtom
|
||||
| '(' selectStatement ')' # subqueryExpressionAtom
|
||||
| KW_INTERVAL expression intervalType # intervalExpressionAtom
|
||||
| left=expressionAtom jsonOperator right=expressionAtom # jsonExpressionAtom
|
||||
| left=expressionAtom bitOperator right=expressionAtom # bitExpressionAtom
|
||||
| left=expressionAtom mathOperator right=expressionAtom # mathExpressionAtom
|
||||
| left=expressionAtom jsonOperator right=expressionAtom # jsonExpressionAtom
|
||||
| columnName # columnNameExpressionAtom
|
||||
;
|
||||
|
||||
unaryOperator
|
||||
@ -2982,18 +2989,18 @@ unaryOperator
|
||||
;
|
||||
|
||||
comparisonOperator
|
||||
: comparisonBase
|
||||
| '<' '>'
|
||||
: '<' '>'
|
||||
| '!' '='
|
||||
| '<' '=' '>'
|
||||
| comparisonBase
|
||||
;
|
||||
|
||||
comparisonBase
|
||||
: '='
|
||||
: '<' '='
|
||||
| '>' '='
|
||||
| '='
|
||||
| '>'
|
||||
| '<'
|
||||
| '<' '='
|
||||
| '>' '='
|
||||
;
|
||||
|
||||
logicalOperator
|
||||
|
@ -42,6 +42,11 @@ parser grammar PostgreSQLParser;
|
||||
options {
|
||||
tokenVocab= PostgreSQLLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
program
|
||||
@ -298,7 +303,7 @@ createschemastmt
|
||||
;
|
||||
|
||||
schema_name_create
|
||||
: colid attrs?
|
||||
: colid attrs? # schemaNameCreate
|
||||
;
|
||||
|
||||
optschemaeltlist
|
||||
@ -469,7 +474,7 @@ altertablestmt
|
||||
| KW_FINALIZE
|
||||
)?
|
||||
| KW_ALTER KW_INDEX opt_if_exists? qualified_name (alter_table_cmds | index_partition_cmd)
|
||||
| KW_ALTER KW_INDEX KW_ALL KW_IN KW_TABLESPACE tablespace_name (KW_OWNED KW_BY role_list)? KW_SET KW_TABLESPACE tablespace_name_create opt_nowait?
|
||||
| KW_ALTER KW_INDEX KW_ALL KW_IN KW_TABLESPACE tablespace_name (KW_OWNED KW_BY role_list)? KW_SET KW_TABLESPACE tablespace_name opt_nowait?
|
||||
| KW_ALTER KW_SEQUENCE opt_if_exists? qualified_name alter_table_cmds
|
||||
| KW_ALTER KW_VIEW opt_if_exists? view_name alter_table_cmds
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name alter_table_cmds
|
||||
@ -538,7 +543,7 @@ alter_table_cmd
|
||||
| KW_FORCE KW_ROW KW_LEVEL KW_SECURITY
|
||||
| KW_NO KW_FORCE KW_ROW KW_LEVEL KW_SECURITY
|
||||
| KW_DROP KW_COLUMN? opt_if_exists? column_name opt_drop_behavior?
|
||||
| KW_ADD KW_COLUMN? opt_if_not_exists? columnDefCluase
|
||||
| KW_ADD KW_COLUMN? opt_if_not_exists? column_def
|
||||
| KW_ALTER KW_COLUMN? column_name alter_column_default
|
||||
| KW_ALTER KW_COLUMN? column_name (KW_DROP | KW_SET) KW_NOT KW_NULL
|
||||
| KW_ALTER KW_COLUMN? column_name KW_DROP KW_EXPRESSION opt_if_exists?
|
||||
@ -674,10 +679,10 @@ copy_opt_item
|
||||
| KW_HEADER
|
||||
| KW_QUOTE opt_as? sconst
|
||||
| KW_ESCAPE opt_as? sconst
|
||||
| KW_FORCE KW_QUOTE columnlist
|
||||
| KW_FORCE KW_QUOTE column_list
|
||||
| KW_FORCE KW_QUOTE STAR
|
||||
| KW_FORCE KW_NOT KW_NULL columnlist
|
||||
| KW_FORCE KW_NULL columnlist
|
||||
| KW_FORCE KW_NOT KW_NULL column_list
|
||||
| KW_FORCE KW_NULL column_list
|
||||
| KW_ENCODING sconst
|
||||
;
|
||||
|
||||
@ -722,7 +727,7 @@ createstmt
|
||||
| KW_OF any_name opttypedtableelementlist? optpartitionspec? table_access_method_clause? optwith? oncommitoption? opttablespace?
|
||||
| KW_PARTITION KW_OF qualified_name opttypedtableelementlist? partitionboundspec optpartitionspec? table_access_method_clause? optwith?
|
||||
oncommitoption? opttablespace?
|
||||
)
|
||||
) # columnCreateTable
|
||||
;
|
||||
|
||||
opttemp
|
||||
@ -754,7 +759,7 @@ typedtableelementlist
|
||||
;
|
||||
|
||||
tableelement
|
||||
: columnDef
|
||||
: column_def
|
||||
| tablelikeclause
|
||||
| tableconstraint
|
||||
;
|
||||
@ -764,14 +769,8 @@ typedtableelement
|
||||
| tableconstraint
|
||||
;
|
||||
|
||||
columnDefCluase
|
||||
: column_name typename create_generic_options? storageCluase? compressionCluase? (
|
||||
KW_COLLATE any_name
|
||||
)? (KW_WITH KW_OPTIONS)? colquallist
|
||||
;
|
||||
|
||||
columnDef
|
||||
: column_name typename create_generic_options? storageCluase? compressionCluase? (
|
||||
column_def
|
||||
: column_name_create typename create_generic_options? storageCluase? compressionCluase? (
|
||||
KW_COLLATE any_name
|
||||
)? (KW_WITH KW_OPTIONS)? colquallist
|
||||
;
|
||||
@ -785,7 +784,7 @@ storageCluase
|
||||
;
|
||||
|
||||
columnOptions
|
||||
: column_name (KW_WITH KW_OPTIONS)? colquallist
|
||||
: column_name_create (KW_WITH KW_OPTIONS)? colquallist
|
||||
;
|
||||
|
||||
colquallist
|
||||
@ -859,16 +858,16 @@ tableconstraint
|
||||
constraintelem
|
||||
: KW_CHECK OPEN_PAREN a_expr CLOSE_PAREN constraintattributespec
|
||||
| KW_UNIQUE (
|
||||
OPEN_PAREN columnlist CLOSE_PAREN opt_c_include? opt_definition? optconstablespace? constraintattributespec
|
||||
OPEN_PAREN column_list CLOSE_PAREN opt_c_include? opt_definition? optconstablespace? constraintattributespec
|
||||
| existingindex constraintattributespec
|
||||
)
|
||||
| KW_PRIMARY KW_KEY (
|
||||
OPEN_PAREN columnlist CLOSE_PAREN opt_c_include? opt_definition? optconstablespace? constraintattributespec
|
||||
OPEN_PAREN column_list CLOSE_PAREN opt_c_include? opt_definition? optconstablespace? constraintattributespec
|
||||
| existingindex constraintattributespec
|
||||
)
|
||||
| KW_EXCLUDE access_method_clause? OPEN_PAREN exclusionconstraintlist CLOSE_PAREN opt_c_include? opt_definition? optconstablespace?
|
||||
exclusionwhereclause? constraintattributespec
|
||||
| KW_FOREIGN KW_KEY OPEN_PAREN columnlist CLOSE_PAREN KW_REFERENCES qualified_name opt_column_list? key_match? key_actions?
|
||||
| KW_FOREIGN KW_KEY OPEN_PAREN column_list CLOSE_PAREN KW_REFERENCES qualified_name opt_column_list? key_match? key_actions?
|
||||
constraintattributespec
|
||||
;
|
||||
|
||||
@ -877,15 +876,23 @@ opt_no_inherit
|
||||
;
|
||||
|
||||
opt_column_list
|
||||
: OPEN_PAREN columnlist CLOSE_PAREN
|
||||
: OPEN_PAREN column_list CLOSE_PAREN
|
||||
;
|
||||
|
||||
columnlist
|
||||
opt_column_list_create
|
||||
: OPEN_PAREN column_list_create CLOSE_PAREN
|
||||
;
|
||||
|
||||
column_list
|
||||
: column_name (COMMA column_name)*
|
||||
;
|
||||
|
||||
column_list_create
|
||||
: column_name_create (COMMA column_name_create)*
|
||||
;
|
||||
|
||||
opt_c_include
|
||||
: KW_INCLUDE OPEN_PAREN columnlist CLOSE_PAREN
|
||||
: KW_INCLUDE OPEN_PAREN column_list CLOSE_PAREN
|
||||
;
|
||||
|
||||
key_match
|
||||
@ -923,7 +930,7 @@ key_action
|
||||
: KW_NO KW_ACTION
|
||||
| KW_RESTRICT
|
||||
| KW_CASCADE
|
||||
| KW_SET (KW_NULL | KW_DEFAULT) columnlist?
|
||||
| KW_SET (KW_NULL | KW_DEFAULT) column_list?
|
||||
;
|
||||
|
||||
optinherit
|
||||
@ -990,11 +997,11 @@ alterstatsstmt
|
||||
;
|
||||
|
||||
createasstmt
|
||||
: KW_CREATE opttemp? KW_TABLE opt_if_not_exists? create_as_target KW_AS selectstmt opt_with_data?
|
||||
: KW_CREATE opttemp? KW_TABLE opt_if_not_exists? create_as_target KW_AS selectstmt opt_with_data? # queryCreateTable
|
||||
;
|
||||
|
||||
create_as_target
|
||||
: table_name_create opt_column_list? table_access_method_clause? optwith? oncommitoption? opttablespace?
|
||||
: table_name_create opt_column_list_create? table_access_method_clause? optwith? oncommitoption? opttablespace?
|
||||
;
|
||||
|
||||
opt_with_data
|
||||
@ -1002,11 +1009,11 @@ opt_with_data
|
||||
;
|
||||
|
||||
creatematviewstmt
|
||||
: KW_CREATE optnolog? KW_MATERIALIZED KW_VIEW opt_if_not_exists? create_mv_target KW_AS selectstmt opt_with_data?
|
||||
: KW_CREATE optnolog? KW_MATERIALIZED KW_VIEW opt_if_not_exists? create_mv_target KW_AS selectstmt opt_with_data? # createMaterializedView
|
||||
;
|
||||
|
||||
create_mv_target
|
||||
: view_name_create opt_column_list? table_access_method_clause? opt_reloptions? opttablespace?
|
||||
: view_name_create opt_column_list_create? table_access_method_clause? opt_reloptions? opttablespace?
|
||||
;
|
||||
|
||||
optnolog
|
||||
@ -1232,9 +1239,9 @@ alterforeignserverstmt
|
||||
|
||||
createforeigntablestmt
|
||||
: KW_CREATE KW_FOREIGN KW_TABLE opt_if_not_exists? table_name_create OPEN_PAREN opttableelementlist? CLOSE_PAREN optinherit? KW_SERVER name
|
||||
create_generic_options?
|
||||
create_generic_options? # createForeignTable
|
||||
| KW_CREATE KW_FOREIGN KW_TABLE opt_if_not_exists? table_name_create KW_PARTITION KW_OF table_name opttypedtableelementlist? partitionboundspec
|
||||
KW_SERVER name create_generic_options?
|
||||
KW_SERVER name create_generic_options? # createPartitionForeignTable
|
||||
;
|
||||
|
||||
importforeignschemastmt
|
||||
@ -1363,7 +1370,7 @@ triggeroneevent
|
||||
: KW_INSERT
|
||||
| KW_DELETE
|
||||
| KW_UPDATE
|
||||
| KW_UPDATE KW_OF columnlist
|
||||
| KW_UPDATE KW_OF column_list
|
||||
| KW_TRUNCATE
|
||||
;
|
||||
|
||||
@ -1806,8 +1813,8 @@ privileges
|
||||
: privilege_list
|
||||
| KW_ALL
|
||||
| KW_ALL KW_PRIVILEGES
|
||||
| KW_ALL OPEN_PAREN columnlist CLOSE_PAREN
|
||||
| KW_ALL KW_PRIVILEGES OPEN_PAREN columnlist CLOSE_PAREN
|
||||
| KW_ALL OPEN_PAREN column_list CLOSE_PAREN
|
||||
| KW_ALL KW_PRIVILEGES OPEN_PAREN column_list CLOSE_PAREN
|
||||
| beforeprivilegeselectlist
|
||||
;
|
||||
|
||||
@ -2350,28 +2357,28 @@ opt_no
|
||||
;
|
||||
|
||||
alterobjectschemastmt
|
||||
: KW_ALTER KW_AGGREGATE aggregate_with_argtypes KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_COLLATION any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_CONVERSION any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_DOMAIN any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_EXTENSION name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_FUNCTION function_with_argtypes KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_OPERATOR operator_with_argtypes KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_OPERATOR KW_CLASS any_name KW_USING name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_OPERATOR KW_FAMILY any_name KW_USING name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_PROCEDURE procedure_with_argtypes KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_ROUTINE routine_with_argtypes KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TABLE opt_if_exists? relation_expr KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_STATISTICS any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_PARSER any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_DICTIONARY any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_TEMPLATE any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_CONFIGURATION any_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_SEQUENCE opt_if_exists? qualified_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_VIEW opt_if_exists? view_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_FOREIGN KW_TABLE opt_if_exists? relation_expr KW_SET KW_SCHEMA schema_name_create
|
||||
| KW_ALTER KW_TYPE any_name KW_SET KW_SCHEMA schema_name_create
|
||||
: KW_ALTER KW_AGGREGATE aggregate_with_argtypes KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_COLLATION any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_CONVERSION any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_DOMAIN any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_EXTENSION name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_FUNCTION function_with_argtypes KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_OPERATOR operator_with_argtypes KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_OPERATOR KW_CLASS any_name KW_USING name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_OPERATOR KW_FAMILY any_name KW_USING name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_PROCEDURE procedure_with_argtypes KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_ROUTINE routine_with_argtypes KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TABLE opt_if_exists? relation_expr KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_STATISTICS any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_PARSER any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_DICTIONARY any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_TEMPLATE any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TEXT KW_SEARCH KW_CONFIGURATION any_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_SEQUENCE opt_if_exists? qualified_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_VIEW opt_if_exists? view_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_FOREIGN KW_TABLE opt_if_exists? relation_expr KW_SET KW_SCHEMA schema_name
|
||||
| KW_ALTER KW_TYPE any_name KW_SET KW_SCHEMA schema_name
|
||||
;
|
||||
|
||||
alteroperatorstmt
|
||||
@ -2571,9 +2578,9 @@ opt_transaction_chain
|
||||
|
||||
viewstmt
|
||||
: KW_CREATE (KW_OR KW_REPLACE)? opttemp? (
|
||||
KW_VIEW view_name_create opt_column_list? opt_reloptions?
|
||||
| KW_RECURSIVE KW_VIEW view_name_create OPEN_PAREN columnlist CLOSE_PAREN opt_reloptions?
|
||||
) KW_AS selectstmt opt_check_option?
|
||||
KW_VIEW view_name_create opt_column_list_create? opt_reloptions?
|
||||
| KW_RECURSIVE KW_VIEW view_name_create OPEN_PAREN column_list CLOSE_PAREN opt_reloptions?
|
||||
) KW_AS selectstmt opt_check_option? # createView
|
||||
;
|
||||
|
||||
opt_check_option
|
||||
@ -2585,7 +2592,7 @@ loadstmt
|
||||
;
|
||||
|
||||
createdbstmt
|
||||
: KW_CREATE KW_DATABASE database_name_create opt_with? createdb_opt_list?
|
||||
: KW_CREATE KW_DATABASE database_name_create opt_with? createdb_opt_list? # createDatabase
|
||||
;
|
||||
|
||||
createdb_opt_list
|
||||
@ -2762,7 +2769,7 @@ opt_freeze
|
||||
;
|
||||
|
||||
opt_name_list
|
||||
: OPEN_PAREN columnlist CLOSE_PAREN
|
||||
: OPEN_PAREN column_list CLOSE_PAREN
|
||||
;
|
||||
|
||||
vacuum_relation
|
||||
@ -2843,7 +2850,7 @@ deallocatestmt
|
||||
;
|
||||
|
||||
insertstmt
|
||||
: opt_with_clause? KW_INSERT KW_INTO insert_target insert_rest opt_on_conflict? returning_clause?
|
||||
: opt_with_clause? KW_INSERT KW_INTO insert_target insert_rest opt_on_conflict? returning_clause? # insertStatement
|
||||
;
|
||||
|
||||
insert_target
|
||||
@ -2971,8 +2978,8 @@ opt_hold
|
||||
*/
|
||||
|
||||
selectstmt
|
||||
: select_no_parens
|
||||
| select_with_parens
|
||||
: select_no_parens # selectStatement
|
||||
| select_with_parens # selectStatement
|
||||
;
|
||||
|
||||
select_with_parens
|
||||
@ -3029,11 +3036,11 @@ common_table_expr
|
||||
;
|
||||
|
||||
search_cluase
|
||||
: KW_SEARCH (KW_BREADTH | KW_DEPTH) KW_FIRST KW_BY columnlist KW_SET column_name
|
||||
: KW_SEARCH (KW_BREADTH | KW_DEPTH) KW_FIRST KW_BY column_list KW_SET column_name
|
||||
;
|
||||
|
||||
cycle_cluase
|
||||
: KW_CYCLE columnlist KW_SET column_name (KW_TO name KW_DEFAULT name)? KW_USING column_name
|
||||
: KW_CYCLE column_list KW_SET column_name (KW_TO name KW_DEFAULT name)? KW_USING column_name
|
||||
;
|
||||
|
||||
opt_materialized
|
||||
@ -3265,7 +3272,7 @@ join_type
|
||||
;
|
||||
|
||||
join_qual
|
||||
: KW_USING OPEN_PAREN columnlist CLOSE_PAREN
|
||||
: KW_USING OPEN_PAREN column_list CLOSE_PAREN
|
||||
| KW_ON a_expr
|
||||
;
|
||||
|
||||
@ -3276,11 +3283,11 @@ relation_expr
|
||||
;
|
||||
|
||||
view_relation_expr
|
||||
: KW_ONLY? view_name STAR?
|
||||
: KW_ONLY? view_name STAR? column_list? where_clause?
|
||||
;
|
||||
|
||||
publication_relation_expr
|
||||
: KW_TABLE KW_ONLY? table_name STAR? (OPEN_PAREN columnlist CLOSE_PAREN)? where_clause?
|
||||
: KW_TABLE KW_ONLY? table_name STAR? (OPEN_PAREN column_list CLOSE_PAREN)? where_clause?
|
||||
| KW_TABLE KW_ONLY ( table_name | OPEN_PAREN table_name CLOSE_PAREN)
|
||||
| KW_TABLES KW_IN KW_SCHEMA (schema_name | KW_CURRENT_SCHEMA)
|
||||
;
|
||||
@ -3949,13 +3956,13 @@ column_expr_list
|
||||
;
|
||||
|
||||
column_expr
|
||||
: column_name
|
||||
| (OPEN_PAREN a_expr CLOSE_PAREN)
|
||||
: (OPEN_PAREN a_expr CLOSE_PAREN)
|
||||
| column_name
|
||||
;
|
||||
|
||||
column_expr_noparen
|
||||
: column_name
|
||||
| a_expr
|
||||
: a_expr
|
||||
| column_name
|
||||
;
|
||||
|
||||
func_arg_list
|
||||
@ -4104,27 +4111,27 @@ procedure_name_list
|
||||
;
|
||||
|
||||
tablespace_name_create
|
||||
: colid indirection?
|
||||
: colid indirection? # tablespaceNameCreate
|
||||
;
|
||||
|
||||
tablespace_name
|
||||
: colid indirection?
|
||||
: colid indirection? # tablespaceName
|
||||
;
|
||||
|
||||
table_name_create
|
||||
: colid indirection?
|
||||
: colid indirection? # tableNameCreate
|
||||
;
|
||||
|
||||
table_name
|
||||
: colid indirection?
|
||||
: colid indirection? # tableName
|
||||
;
|
||||
|
||||
view_name_create
|
||||
: colid indirection?
|
||||
: colid indirection? # viewNameCreate
|
||||
;
|
||||
|
||||
view_name
|
||||
: colid attrs?
|
||||
: colid attrs? # viewName
|
||||
;
|
||||
|
||||
qualified_name
|
||||
@ -4140,41 +4147,42 @@ name_list
|
||||
;
|
||||
|
||||
database_name_create
|
||||
: colid attrs?
|
||||
: colid attrs? # databaseNameCreate
|
||||
;
|
||||
|
||||
database_name
|
||||
: colid attrs?
|
||||
: colid attrs? # databaseName
|
||||
;
|
||||
|
||||
schema_name
|
||||
: colid attrs?
|
||||
: colid attrs? # schemaName
|
||||
;
|
||||
|
||||
routine_name_create
|
||||
: colid
|
||||
: colid # routineNameCreate
|
||||
;
|
||||
|
||||
routine_name
|
||||
: colid
|
||||
: colid # routineName
|
||||
;
|
||||
|
||||
procedure_name
|
||||
: type_function_name
|
||||
| colid indirection
|
||||
: type_function_name # procedureName
|
||||
| colid indirection # procedureName
|
||||
;
|
||||
|
||||
procedure_name_create
|
||||
: type_function_name
|
||||
| colid indirection
|
||||
: type_function_name # procedureNameCreate
|
||||
| colid indirection # procedureNameCreate
|
||||
;
|
||||
|
||||
column_name
|
||||
: colid indirection_el*
|
||||
: colid indirection_el* # columnName
|
||||
| {this.shouldMatchEmpty()}? # columnNameMatch
|
||||
;
|
||||
|
||||
column_name_create
|
||||
: colid
|
||||
: colid # columnNameCreate
|
||||
;
|
||||
|
||||
name
|
||||
@ -4190,13 +4198,13 @@ file_name
|
||||
;
|
||||
|
||||
function_name_create
|
||||
: type_function_name
|
||||
| colid indirection
|
||||
: type_function_name # functionNameCreate
|
||||
| colid indirection # functionNameCreate
|
||||
;
|
||||
|
||||
function_name
|
||||
: type_function_name
|
||||
| colid indirection
|
||||
: type_function_name # functionName
|
||||
| colid indirection # functionName
|
||||
;
|
||||
|
||||
usual_name
|
||||
@ -5353,13 +5361,15 @@ merge_when_clause
|
||||
;
|
||||
|
||||
merge_insert
|
||||
: KW_INSERT (OPEN_PAREN columnlist CLOSE_PAREN)? (KW_OVERRIDING (KW_SYSTEM | KW_USER) KW_VALUE)? default_values_or_values
|
||||
: KW_INSERT (OPEN_PAREN column_list CLOSE_PAREN)? (
|
||||
KW_OVERRIDING (KW_SYSTEM | KW_USER) KW_VALUE
|
||||
)? default_values_or_values
|
||||
;
|
||||
|
||||
merge_update
|
||||
: KW_UPDATE KW_SET (
|
||||
column_name EQUAL exprofdefault
|
||||
| OPEN_PAREN columnlist CLOSE_PAREN EQUAL OPEN_PAREN exprofdefaultlist CLOSE_PAREN
|
||||
| OPEN_PAREN column_list CLOSE_PAREN EQUAL OPEN_PAREN exprofdefaultlist CLOSE_PAREN
|
||||
)+
|
||||
;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/**
|
||||
* This file is an adaptation of spark's spark/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4 grammar.
|
||||
* Reference: https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4
|
||||
* Reference: https://github.com/apache/spark/blob/v3.5.0/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseLexer.g4
|
||||
*/
|
||||
|
||||
// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
/**
|
||||
* This file is an adaptation of spark's spark/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4 grammar.
|
||||
* Reference: https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
|
||||
* Reference: https://github.com/apache/spark/blob/v3.5.0/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4
|
||||
*/
|
||||
|
||||
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
||||
@ -27,6 +27,11 @@ parser grammar SparkSqlParser;
|
||||
options {
|
||||
tokenVocab=SparkSqlLexer;
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
program
|
||||
@ -38,78 +43,78 @@ singleStatement
|
||||
;
|
||||
|
||||
statement
|
||||
: query
|
||||
| ctes? dmlStatementNoWith
|
||||
| KW_USE dbSchemaName
|
||||
| KW_USE dbSchema dbSchemaName
|
||||
| KW_SET KW_CATALOG (identifier | stringLit)
|
||||
| KW_CREATE dbSchema (ifNotExists)? dbSchemaNameCreate (
|
||||
: query # statementDefault
|
||||
| ctes? dmlStatementNoWith # dmlStatement
|
||||
| KW_USE namespace? namespaceName # useNamespace
|
||||
| KW_SET KW_CATALOG (identifier | stringLit) # setCatalog
|
||||
| KW_CREATE namespace (ifNotExists)? namespaceNameCreate (
|
||||
commentSpec
|
||||
| locationSpec
|
||||
| (KW_WITH (KW_DBPROPERTIES | KW_PROPERTIES) propertyList)
|
||||
)*
|
||||
| KW_ALTER dbSchema dbSchemaName KW_SET (KW_DBPROPERTIES | KW_PROPERTIES) propertyList
|
||||
| KW_ALTER dbSchema dbSchemaName KW_SET locationSpec
|
||||
| KW_DROP dbSchema (ifExists)? dbSchemaName (KW_RESTRICT | KW_CASCADE)?
|
||||
| KW_SHOW dbSchemas ((KW_FROM | KW_IN) multipartIdentifier)? (KW_LIKE? pattern=stringLit)?
|
||||
)* # createNamespace
|
||||
| KW_ALTER namespace namespaceName KW_SET (KW_DBPROPERTIES | KW_PROPERTIES) propertyList # setNamespaceProperties
|
||||
| KW_ALTER namespace namespaceName KW_SET locationSpec # setNamespaceLocation
|
||||
| KW_DROP namespace (ifExists)? namespaceName (KW_RESTRICT | KW_CASCADE)? # dropNamespace
|
||||
| KW_SHOW namespaces ((KW_FROM | KW_IN) multipartIdentifier)? (KW_LIKE? pattern=stringLit)? # showNamespaces
|
||||
| createTableHeader (LEFT_PAREN createOrReplaceTableColTypeList RIGHT_PAREN)? tableProvider? createTableClauses (
|
||||
KW_AS? query
|
||||
)?
|
||||
)? # createTable
|
||||
| KW_CREATE KW_TABLE (ifNotExists)? target=tableNameCreate KW_LIKE source=tableName (
|
||||
tableProvider
|
||||
| rowFormat
|
||||
| createFileFormat
|
||||
| locationSpec
|
||||
| (KW_TBLPROPERTIES tableProps=propertyList)
|
||||
)*
|
||||
)* # createTableLike
|
||||
| replaceTableHeader (LEFT_PAREN createOrReplaceTableColTypeList RIGHT_PAREN)? tableProvider? createTableClauses (
|
||||
KW_AS? query
|
||||
)?
|
||||
)? # replaceTable
|
||||
| KW_ANALYZE KW_TABLE tableName partitionSpec? KW_COMPUTE KW_STATISTICS (
|
||||
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 (KW_NOSCAN)?
|
||||
| KW_ALTER KW_TABLE tableName KW_ADD KW_COLUMN qualifiedColTypeWithPositionForAdd
|
||||
| KW_ALTER KW_TABLE tableName KW_ADD KW_COLUMNS LEFT_PAREN qualifiedColTypeWithPositionSeqForAdd RIGHT_PAREN
|
||||
| KW_ALTER KW_TABLE table=tableName KW_RENAME KW_COLUMN columnName KW_TO columnNameCreate
|
||||
| KW_ALTER KW_TABLE tableName KW_DROP KW_COLUMN (ifExists)? columnName
|
||||
| KW_ALTER KW_TABLE tableName 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) KW_SET KW_TBLPROPERTIES propertyList
|
||||
| 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=columnName alterColumnAction?
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec? KW_CHANGE KW_COLUMN? colName=columnName colType colPosition?
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec? KW_REPLACE KW_COLUMNS LEFT_PAREN qualifiedColTypeWithPositionSeqForReplace RIGHT_PAREN
|
||||
)? # analyze
|
||||
| KW_ANALYZE KW_TABLES ((KW_FROM | KW_IN) namespaceName)? KW_COMPUTE KW_STATISTICS (KW_NOSCAN)? # analyzeTables
|
||||
| KW_ALTER KW_TABLE tableName KW_ADD KW_COLUMN qualifiedColTypeWithPositionForAdd # alterTableAddColumn
|
||||
| KW_ALTER KW_TABLE tableName KW_ADD KW_COLUMNS LEFT_PAREN qualifiedColTypeWithPositionSeqForAdd RIGHT_PAREN # alterTableAddColumns
|
||||
| KW_ALTER KW_TABLE table=tableName KW_RENAME KW_COLUMN columnName KW_TO columnNameCreate # renameTableColumn
|
||||
| KW_ALTER KW_TABLE tableName KW_DROP KW_COLUMN (ifExists)? columnName # alterTableDropColumn
|
||||
| KW_ALTER KW_TABLE tableName KW_DROP KW_COLUMNS (ifExists)? LEFT_PAREN columnNameSeq RIGHT_PAREN # dropTableColumns
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_RENAME KW_TO multipartIdentifier # renameTable
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_SET KW_TBLPROPERTIES propertyList # setTableProperties
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_UNSET KW_TBLPROPERTIES (ifExists)? propertyList # unsetTableProperties
|
||||
| KW_ALTER KW_TABLE table=tableName (KW_ALTER | KW_CHANGE) KW_COLUMN? column=columnName alterColumnAction? # alterTableAlterColumn
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec? KW_CHANGE KW_COLUMN? colName=columnName colType colPosition? # hiveChangeColumn
|
||||
| KW_ALTER KW_TABLE table=tableName partitionSpec? KW_REPLACE KW_COLUMNS LEFT_PAREN qualifiedColTypeWithPositionSeqForReplace RIGHT_PAREN #
|
||||
hiveReplaceColumns
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)? KW_SET KW_SERDE stringLit (
|
||||
KW_WITH KW_SERDEPROPERTIES propertyList
|
||||
)?
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)? KW_SET KW_SERDEPROPERTIES propertyList
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_ADD (ifNotExists)? partitionSpecLocation+
|
||||
| KW_ALTER KW_TABLE tableName partitionSpec KW_RENAME KW_TO partitionSpec
|
||||
)? # setTableSerDe
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)? KW_SET KW_SERDEPROPERTIES propertyList # setTableSerDeProperties
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_ADD (ifNotExists)? partitionSpecLocation+ # addTablePartition
|
||||
| KW_ALTER KW_TABLE tableName partitionSpec KW_RENAME KW_TO partitionSpec # renameTablePartition
|
||||
| KW_ALTER (KW_TABLE tableName | KW_VIEW viewName) KW_DROP (ifExists)? partitionSpec (
|
||||
COMMA partitionSpec
|
||||
)* KW_PURGE?
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)? KW_SET locationSpec
|
||||
| KW_ALTER KW_TABLE tableName KW_RECOVER KW_PARTITIONS
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW viewName (KW_ENABLE | KW_DISABLE) KW_REWRITE
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW viewName KW_SET KW_TBLPROPERTIES propertyList
|
||||
| KW_DROP KW_TABLE (ifExists)? tableName KW_PURGE?
|
||||
| KW_DROP KW_VIEW (ifExists)? viewName
|
||||
| KW_DROP KW_MATERIALIZED KW_VIEW (ifExists)? viewName
|
||||
)* KW_PURGE? # dropTablePartitions
|
||||
| KW_ALTER KW_TABLE tableName (partitionSpec)? KW_SET locationSpec # setTableLocation
|
||||
| KW_ALTER KW_TABLE tableName KW_RECOVER KW_PARTITIONS # recoverPartitions
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW viewName (KW_ENABLE | KW_DISABLE) KW_REWRITE # alterMaterializedViewRewrite
|
||||
| KW_ALTER KW_MATERIALIZED KW_VIEW viewName KW_SET KW_TBLPROPERTIES propertyList # alterMaterializedViewProperties
|
||||
| KW_DROP KW_TABLE (ifExists)? tableName KW_PURGE? # dropTable
|
||||
| KW_DROP KW_VIEW (ifExists)? viewName # dropView
|
||||
| KW_DROP KW_MATERIALIZED KW_VIEW (ifExists)? viewName # dropMaterializedView
|
||||
| KW_CREATE (KW_OR KW_REPLACE)? (KW_GLOBAL? KW_TEMPORARY)? KW_VIEW (ifNotExists)? viewNameCreate identifierCommentList? (
|
||||
commentSpec
|
||||
| (KW_PARTITIONED KW_ON identifierList)
|
||||
| (KW_TBLPROPERTIES propertyList)
|
||||
)* KW_AS query
|
||||
)* KW_AS query # createView
|
||||
| KW_CREATE (KW_OR KW_REPLACE)? KW_GLOBAL? KW_TEMPORARY KW_VIEW viewNameCreate (
|
||||
LEFT_PAREN colTypeList RIGHT_PAREN
|
||||
)? tableProvider (KW_OPTIONS propertyList)?
|
||||
| KW_ALTER KW_VIEW viewName KW_AS? query
|
||||
)? tableProvider (KW_OPTIONS propertyList)? # createTempViewUsing
|
||||
| KW_ALTER KW_VIEW viewName KW_AS? query # alterViewQuery
|
||||
| KW_CREATE (KW_OR KW_REPLACE)? KW_TEMPORARY? KW_FUNCTION (ifNotExists)? functionNameCreate KW_AS className=stringLit (
|
||||
KW_USING resource (COMMA resource)*
|
||||
)?
|
||||
)? # createFunction
|
||||
|
|
||||
// Self developed materialized view syntax by dtstack, spark not support now.
|
||||
KW_CREATE KW_MATERIALIZED KW_VIEW (ifNotExists)? viewNameCreate tableProvider? (
|
||||
@ -122,62 +127,62 @@ statement
|
||||
| locationSpec
|
||||
| commentSpec
|
||||
| (KW_TBLPROPERTIES tableProps=propertyList)
|
||||
)* KW_AS query
|
||||
| KW_DROP KW_TEMPORARY? KW_FUNCTION (ifExists)? functionName
|
||||
| KW_DECLARE (KW_OR KW_REPLACE)? KW_VARIABLE? functionName dataType? variableDefaultExpression?
|
||||
| KW_DROP KW_TEMPORARY KW_VARIABLE (ifExists)? (tableName | viewName | functionName)
|
||||
| KW_EXPLAIN (KW_LOGICAL | KW_FORMATTED | KW_EXTENDED | KW_CODEGEN | KW_COST)? statement
|
||||
| KW_SHOW KW_TABLES ((KW_FROM | KW_IN) dbSchemaName)? (KW_LIKE? pattern=stringLit)?
|
||||
| KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM | KW_IN) ns=dbSchemaName)? KW_LIKE pattern=stringLit partitionSpec?
|
||||
| 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) dbSchemaName)?
|
||||
| KW_SHOW KW_VIEWS ((KW_FROM | KW_IN) dbSchemaName)? (KW_LIKE? pattern=stringLit)?
|
||||
| KW_SHOW KW_PARTITIONS tableName partitionSpec?
|
||||
| KW_SHOW functionKind? KW_FUNCTIONS ((KW_FROM | KW_IN) ns=dbSchemaName)? (
|
||||
)* KW_AS query # createMaterializedView
|
||||
| KW_DROP KW_TEMPORARY? KW_FUNCTION (ifExists)? functionName # dropFunction
|
||||
| KW_DECLARE (KW_OR KW_REPLACE)? KW_VARIABLE? functionName dataType? variableDefaultExpression? # declareVariable
|
||||
| KW_DROP KW_TEMPORARY KW_VARIABLE (ifExists)? (tableName | viewName | functionName) # dropVariable
|
||||
| KW_EXPLAIN (KW_LOGICAL | KW_FORMATTED | KW_EXTENDED | KW_CODEGEN | KW_COST)? statement # explainStatement
|
||||
| KW_SHOW KW_TABLES ((KW_FROM | KW_IN) namespaceName)? (KW_LIKE? pattern=stringLit)? # showTables
|
||||
| KW_SHOW KW_TABLE KW_EXTENDED ((KW_FROM | KW_IN) ns=namespaceName)? KW_LIKE pattern=stringLit partitionSpec? # showTableExtended
|
||||
| KW_SHOW KW_TBLPROPERTIES table=tableName (LEFT_PAREN key=propertyKey RIGHT_PAREN)? # showTblProperties
|
||||
| KW_SHOW KW_COLUMNS (KW_FROM | KW_IN) table=tableName ((KW_FROM | KW_IN) namespaceName)? # showColumns
|
||||
| KW_SHOW KW_VIEWS ((KW_FROM | KW_IN) namespaceName)? (KW_LIKE? pattern=stringLit)? # showViews
|
||||
| KW_SHOW KW_PARTITIONS tableName partitionSpec? # showPartitions
|
||||
| KW_SHOW functionKind? KW_FUNCTIONS ((KW_FROM | KW_IN) ns=namespaceName)? (
|
||||
KW_LIKE? (legacy=multipartIdentifier | pattern=stringLit)
|
||||
)?
|
||||
| KW_SHOW KW_CREATE KW_TABLE tableName (KW_AS KW_SERDE)?
|
||||
| KW_SHOW KW_CURRENT dbSchema
|
||||
| KW_SHOW KW_CATALOGS (KW_LIKE? pattern=stringLit)?
|
||||
| KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM | KW_IN) db_name=dbSchemaName)? (
|
||||
)? # showFunctions
|
||||
| KW_SHOW KW_CREATE KW_TABLE tableName (KW_AS KW_SERDE)? # showCreateTable
|
||||
| KW_SHOW KW_CURRENT namespace # showCurrentNamespace
|
||||
| KW_SHOW KW_CATALOGS (KW_LIKE? pattern=stringLit)? # showCatalogs
|
||||
| KW_SHOW KW_MATERIALIZED KW_VIEWS ((KW_FROM | KW_IN) db_name=namespaceName)? (
|
||||
KW_LIKE? pattern=stringLit
|
||||
)?
|
||||
| KW_SHOW KW_CREATE KW_MATERIALIZED KW_VIEW viewName (KW_AS KW_SERDE)?
|
||||
| (KW_DESC | KW_DESCRIBE) KW_FUNCTION KW_EXTENDED? describeFuncName
|
||||
| (KW_DESC | KW_DESCRIBE) KW_DATABASE KW_EXTENDED? dbSchemaName
|
||||
| (KW_DESC | KW_DESCRIBE) KW_TABLE? option=(KW_EXTENDED | KW_FORMATTED)? tableName partitionSpec? describeColName?
|
||||
| (KW_DESC | KW_DESCRIBE) KW_QUERY? query
|
||||
| KW_COMMENT KW_ON dbSchema dbSchemaName KW_IS comment
|
||||
| KW_COMMENT KW_ON KW_TABLE tableName KW_IS comment
|
||||
| KW_REFRESH KW_TABLE tableName
|
||||
| KW_REFRESH KW_FUNCTION functionName
|
||||
| KW_REFRESH (stringLit | .*?)
|
||||
| KW_REFRESH KW_MATERIALIZED KW_VIEW viewName
|
||||
| KW_CACHE KW_LAZY? KW_TABLE tableName (KW_OPTIONS options=propertyList)? (KW_AS? query)?
|
||||
| KW_UNCACHE KW_TABLE (ifExists)? tableName
|
||||
| KW_CLEAR KW_CACHE
|
||||
| KW_LOAD KW_DATA KW_LOCAL? KW_INPATH path=stringLit KW_OVERWRITE? KW_INTO KW_TABLE tableName partitionSpec?
|
||||
| KW_TRUNCATE KW_TABLE tableName partitionSpec?
|
||||
| (KW_MSCK)? KW_REPAIR KW_TABLE tableName (option=(KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)?
|
||||
| op=(KW_ADD | KW_LIST) identifier .*?
|
||||
| KW_SET KW_ROLE .*?
|
||||
| KW_SET KW_TIME KW_ZONE interval
|
||||
| KW_SET KW_TIME KW_ZONE timezone
|
||||
| KW_SET KW_TIME KW_ZONE .*?
|
||||
| KW_SET (KW_VARIABLE | KW_VAR) assignmentList
|
||||
| KW_SET (KW_VARIABLE | KW_VAR) LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ LEFT_PAREN query RIGHT_PAREN
|
||||
| KW_SET configKey EQ configValue
|
||||
| KW_SET configKey (EQ .*?)?
|
||||
| KW_SET .*? EQ configValue
|
||||
| KW_SET .*?
|
||||
| KW_RESET configKey
|
||||
| KW_RESET .*?
|
||||
)? # showMaterializedViews
|
||||
| KW_SHOW KW_CREATE KW_MATERIALIZED KW_VIEW viewName (KW_AS KW_SERDE)? # showCreateMaterializedView
|
||||
| (KW_DESC | KW_DESCRIBE) KW_FUNCTION KW_EXTENDED? describeFuncName # describeFunction
|
||||
| (KW_DESC | KW_DESCRIBE) KW_DATABASE KW_EXTENDED? namespaceName # describeNamespace
|
||||
| (KW_DESC | KW_DESCRIBE) KW_TABLE? option=(KW_EXTENDED | KW_FORMATTED)? tableName partitionSpec? describeColName? # describeRelation
|
||||
| (KW_DESC | KW_DESCRIBE) KW_QUERY? query # describeQuery
|
||||
| KW_COMMENT KW_ON namespace namespaceName KW_IS comment # commentNamespace
|
||||
| KW_COMMENT KW_ON KW_TABLE tableName KW_IS comment # commentTable
|
||||
| KW_REFRESH KW_TABLE tableName # refreshTable
|
||||
| KW_REFRESH KW_FUNCTION functionName # refreshFunction
|
||||
| KW_REFRESH (stringLit | .*?) # refreshResource
|
||||
| KW_REFRESH KW_MATERIALIZED KW_VIEW viewName # refreshMaterializedView
|
||||
| KW_CACHE KW_LAZY? KW_TABLE tableName (KW_OPTIONS options=propertyList)? (KW_AS? query)? # cacheTable
|
||||
| KW_UNCACHE KW_TABLE (ifExists)? tableName # unCacheTable
|
||||
| KW_CLEAR KW_CACHE # clearCache
|
||||
| KW_LOAD KW_DATA KW_LOCAL? KW_INPATH path=stringLit KW_OVERWRITE? KW_INTO KW_TABLE tableName partitionSpec? # loadData
|
||||
| KW_TRUNCATE KW_TABLE tableName partitionSpec? # truncateTable
|
||||
| (KW_MSCK)? KW_REPAIR KW_TABLE tableName (option=(KW_ADD | KW_DROP | KW_SYNC) KW_PARTITIONS)? # repairTable
|
||||
| op=(KW_ADD | KW_LIST) identifier .*? # manageResource
|
||||
| KW_SET KW_ROLE .*? # failNativeCommand
|
||||
| KW_SET KW_TIME KW_ZONE interval # setTimeZoneInterval
|
||||
| KW_SET KW_TIME KW_ZONE timezone # setTimeZone
|
||||
| KW_SET KW_TIME KW_ZONE .*? # setTimeZoneAny
|
||||
| KW_SET (KW_VARIABLE | KW_VAR) assignmentList # setVariableAssignment
|
||||
| KW_SET (KW_VARIABLE | KW_VAR) LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ LEFT_PAREN query RIGHT_PAREN # setVariableMultiAssignment
|
||||
| KW_SET configKey EQ configValue # setConfig
|
||||
| KW_SET configKey (EQ .*?)? # setConfigAndValue
|
||||
| KW_SET .*? EQ configValue # setConfigAnyKey
|
||||
| KW_SET .*? # setAny
|
||||
| KW_RESET configKey # resetConfig
|
||||
| KW_RESET .*? # resetAny
|
||||
| KW_CREATE KW_INDEX (ifNotExists)? identifier KW_ON KW_TABLE? tableName (
|
||||
KW_USING indexType=identifier
|
||||
)? LEFT_PAREN multipartIdentifierPropertyList RIGHT_PAREN (KW_OPTIONS options=propertyList)?
|
||||
| KW_DROP KW_INDEX (ifExists)? identifier KW_ON KW_TABLE? tableName
|
||||
| KW_OPTIMIZE tableName whereClause? zorderClause
|
||||
| unsupportedHiveNativeCommands .*?
|
||||
)? LEFT_PAREN multipartIdentifierPropertyList RIGHT_PAREN (KW_OPTIONS options=propertyList)? # createIndex
|
||||
| KW_DROP KW_INDEX (ifExists)? identifier KW_ON KW_TABLE? tableName # dropIndex
|
||||
| KW_OPTIMIZE tableName whereClause? zorderClause # optimizeTable
|
||||
| unsupportedHiveNativeCommands .*? # unsupportHiveCommands
|
||||
;
|
||||
|
||||
timezone
|
||||
@ -267,7 +272,7 @@ commentSpec
|
||||
;
|
||||
|
||||
query
|
||||
: ctes? queryTerm queryOrganization
|
||||
: ctes? queryTerm queryOrganization # queryStatement
|
||||
;
|
||||
|
||||
insertInto
|
||||
@ -299,13 +304,13 @@ partitionVal
|
||||
| identifier EQ KW_DEFAULT
|
||||
;
|
||||
|
||||
dbSchema
|
||||
namespace
|
||||
: KW_NAMESPACE
|
||||
| KW_DATABASE
|
||||
| KW_SCHEMA
|
||||
;
|
||||
|
||||
dbSchemas
|
||||
namespaces
|
||||
: KW_NAMESPACES
|
||||
| KW_DATABASES
|
||||
| KW_SCHEMAS
|
||||
@ -404,21 +409,21 @@ resource
|
||||
;
|
||||
|
||||
dmlStatementNoWith
|
||||
: insertInto query
|
||||
| fromClause multiInsertQueryBody+
|
||||
| KW_DELETE KW_FROM tableName tableAlias whereClause?
|
||||
| KW_UPDATE tableName tableAlias setClause whereClause?
|
||||
: insertInto query # insertFromQuery
|
||||
| fromClause multiInsertQueryBody+ # multipleInsert
|
||||
| KW_DELETE KW_FROM tableName tableAlias whereClause? # deleteFromTable
|
||||
| KW_UPDATE tableName tableAlias setClause whereClause? # updateTable
|
||||
| KW_MERGE KW_INTO target=tableName targetAlias=tableAlias KW_USING (
|
||||
source=identifierReference
|
||||
| LEFT_PAREN sourceQuery=query RIGHT_PAREN
|
||||
) sourceAlias=tableAlias KW_ON mergeCondition=booleanExpression matchedClause* notMatchedClause* notMatchedBySourceClause*
|
||||
) sourceAlias=tableAlias KW_ON mergeCondition=booleanExpression matchedClause* notMatchedClause* notMatchedBySourceClause* # mergeIntoTable
|
||||
;
|
||||
|
||||
dbSchemaName
|
||||
namespaceName
|
||||
: identifierReference
|
||||
;
|
||||
|
||||
dbSchemaNameCreate
|
||||
namespaceNameCreate
|
||||
: identifierReference
|
||||
;
|
||||
|
||||
@ -440,6 +445,7 @@ viewName
|
||||
|
||||
columnName
|
||||
: multipartIdentifier
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
columnNameSeq
|
||||
@ -782,11 +788,11 @@ identifierCommentList
|
||||
;
|
||||
|
||||
identifierComment
|
||||
: identifier commentSpec?
|
||||
: columnNameCreate commentSpec?
|
||||
;
|
||||
|
||||
relationPrimary
|
||||
: identifierReference temporalClause? sample? tableAlias
|
||||
: (tableName | viewName | identifierReference) temporalClause? sample? tableAlias
|
||||
| LEFT_PAREN query RIGHT_PAREN sample? tableAlias
|
||||
| LEFT_PAREN relation RIGHT_PAREN sample? tableAlias
|
||||
| inlineTable
|
||||
@ -1811,7 +1817,7 @@ nonReserved
|
||||
| KW_FOREIGN
|
||||
| KW_FORMAT
|
||||
| KW_FORMATTED
|
||||
| KW_FROM
|
||||
// | KW_FROM
|
||||
| KW_FUNCTION
|
||||
| KW_FUNCTIONS
|
||||
| KW_GENERATED
|
||||
@ -1967,7 +1973,7 @@ nonReserved
|
||||
| KW_SYSTEM
|
||||
| KW_SYSTEM_TIME
|
||||
| KW_SYSTEM_VERSION
|
||||
| KW_TABLE
|
||||
// | KW_TABLE
|
||||
| KW_TABLES
|
||||
| KW_TABLESAMPLE
|
||||
| KW_TARGET
|
||||
|
@ -25,6 +25,11 @@ grammar TrinoSql;
|
||||
|
||||
options {
|
||||
caseInsensitive= true;
|
||||
superClass=SQLParserBase;
|
||||
}
|
||||
|
||||
@header {
|
||||
import SQLParserBase from '../SQLParserBase';
|
||||
}
|
||||
|
||||
tokens {
|
||||
@ -173,12 +178,12 @@ 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 columnName # showColumnComment
|
||||
| KW_SHOW KW_COMMENT KW_ON KW_TABLE tableName # showTableComment // dtstack
|
||||
| KW_SHOW KW_COMMENT KW_ON KW_COLUMN columnName # showColumnComment // dtstack
|
||||
;
|
||||
|
||||
query
|
||||
: with? queryNoWith
|
||||
: with? queryNoWith # queryStatement
|
||||
;
|
||||
|
||||
with
|
||||
@ -746,6 +751,7 @@ functionName
|
||||
|
||||
columnName
|
||||
: qualifiedName
|
||||
| {this.shouldMatchEmpty()}?
|
||||
;
|
||||
|
||||
columnNameCreate
|
||||
|
Reference in New Issue
Block a user