Skip to content

Commit ebd9a1e

Browse files
HaydenOrzwewoor
authored andcommitted
feat: hiveSQL support create/drop/alter index grammar
1 parent 28de63e commit ebd9a1e

5 files changed

Lines changed: 7949 additions & 7900 deletions

File tree

src/grammar/hive/HiveSqlParser.g4

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ options
2121
tokenVocab=HiveSqlLexer;
2222
}
2323

24-
program : statement EOF;
24+
program : statement* EOF;
2525

2626
// starting rule
2727
statement
28-
: (explainStatement | execStatement) SEMICOLON? EOF
28+
: (explainStatement | execStatement) SEMICOLON?
2929
;
3030

3131
explainStatement
@@ -160,6 +160,8 @@ ddlStatement
160160
| dropFunctionStatement
161161
| reloadFunctionsStatement
162162
| dropMacroStatement
163+
| createIndexStatement
164+
| dropIndexStatement
163165
| analyzeStatement
164166
| lockStatement
165167
| unlockStatement
@@ -540,6 +542,20 @@ dropMacroStatement
540542
: KW_DROP KW_TEMPORARY KW_MACRO ifExists? Identifier
541543
;
542544

545+
createIndexStatement
546+
: KW_CREATE KW_INDEX id_ KW_ON KW_TABLE tableName columnParenthesesList KW_AS indextype=StringLiteral
547+
(KW_WITH KW_DEFERRED KW_REBUILD)?
548+
(KW_IDXPROPERTIES tableProperties)?
549+
(KW_IN KW_TABLE tableName)?
550+
(KW_PARTITIONED KW_BY columnParenthesesList)?
551+
(tableRowFormat? tableFileFormat)?
552+
(KW_LOCATION locn=StringLiteral)?
553+
tablePropertiesPrefixed?
554+
tableComment?;
555+
556+
dropIndexStatement
557+
: KW_DROP KW_INDEX ifExists? id_ KW_ON tableName;
558+
543559
createViewStatement
544560
: KW_CREATE orReplace? KW_VIEW ifNotExists? name=tableName
545561
(LPAREN columnNameCommentList RPAREN)? tableComment? viewPartition?
@@ -1314,6 +1330,7 @@ alterStatement
13141330
| KW_MATERIALIZED KW_VIEW tableNameTree=tableName alterMaterializedViewStatementSuffix
13151331
| db_schema alterDatabaseStatementSuffix
13161332
| KW_DATACONNECTOR alterDataConnectorStatementSuffix
1333+
| KW_INDEX alterIndexStatementSuffix
13171334
)
13181335
;
13191336

@@ -1570,6 +1587,11 @@ alterStatementSuffixExecute
15701587
) RPAREN
15711588
;
15721589

1590+
alterIndexStatementSuffix
1591+
: id_ KW_ON tableName
1592+
partitionSpec?
1593+
KW_REBUILD;
1594+
15731595
fileFormat
15741596
: KW_INPUTFORMAT inFmt=StringLiteral KW_OUTPUTFORMAT outFmt=StringLiteral KW_SERDE serdeCls=StringLiteral
15751597
(KW_INPUTDRIVER inDriver=StringLiteral KW_OUTPUTDRIVER outDriver=StringLiteral)?

src/lib/hive/HiveSqlParser.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)