feat: hiveSQL support create/drop/alter index grammar

This commit is contained in:
hayden
2023-07-07 11:18:27 +08:00
committed by Ziv
parent 28de63e1f0
commit ebd9a1ed85
5 changed files with 7949 additions and 7900 deletions

View File

@ -21,11 +21,11 @@ options
tokenVocab=HiveSqlLexer;
}
program : statement EOF;
program : statement* EOF;
// starting rule
statement
: (explainStatement | execStatement) SEMICOLON? EOF
: (explainStatement | execStatement) SEMICOLON?
;
explainStatement
@ -160,6 +160,8 @@ ddlStatement
| dropFunctionStatement
| reloadFunctionsStatement
| dropMacroStatement
| createIndexStatement
| dropIndexStatement
| analyzeStatement
| lockStatement
| unlockStatement
@ -540,6 +542,20 @@ dropMacroStatement
: KW_DROP KW_TEMPORARY KW_MACRO ifExists? Identifier
;
createIndexStatement
: KW_CREATE KW_INDEX id_ KW_ON KW_TABLE tableName columnParenthesesList KW_AS indextype=StringLiteral
(KW_WITH KW_DEFERRED KW_REBUILD)?
(KW_IDXPROPERTIES tableProperties)?
(KW_IN KW_TABLE tableName)?
(KW_PARTITIONED KW_BY columnParenthesesList)?
(tableRowFormat? tableFileFormat)?
(KW_LOCATION locn=StringLiteral)?
tablePropertiesPrefixed?
tableComment?;
dropIndexStatement
: KW_DROP KW_INDEX ifExists? id_ KW_ON tableName;
createViewStatement
: KW_CREATE orReplace? KW_VIEW ifNotExists? name=tableName
(LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition?
@ -1314,6 +1330,7 @@ alterStatement
| KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix
| db_schema alterDatabaseStatementSuffix
| KW_DATACONNECTOR alterDataConnectorStatementSuffix
| KW_INDEX alterIndexStatementSuffix
)
;
@ -1570,6 +1587,11 @@ alterStatementSuffixExecute
) RPAREN
;
alterIndexStatementSuffix
: id_ KW_ON tableName
partitionSpec?
KW_REBUILD;
fileFormat
: KW_INPUTFORMAT inFmt=StringLiteral KW_OUTPUTFORMAT outFmt=StringLiteral KW_SERDE serdeCls=StringLiteral
(KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)?