Skip to content

Commit

Permalink
check alter sql and syntax (#156)
Browse files Browse the repository at this point in the history
* check and update abort and alter sql

* delete superfluous space

* update grammar lib after change alter parser

* update alter parser to be compatible

---------

Co-authored-by: zhaoge <>
  • Loading branch information
Cythia828 authored Sep 6, 2023
1 parent ded9f28 commit 6dad62d
Show file tree
Hide file tree
Showing 17 changed files with 12,120 additions and 11,610 deletions.
1 change: 1 addition & 0 deletions src/grammar/hive/HiveSqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ KW_DISTRIBUTED : 'DISTRIBUTED';
KW_DO : 'DO';
KW_DOUBLE : 'DOUBLE';
KW_DROP : 'DROP';
KW_RECOVER : 'RECOVER';
KW_DUMP : 'DUMP';
KW_ELEM_TYPE : '$ELEM$';
KW_ELSE : 'ELSE';
Expand Down
23 changes: 19 additions & 4 deletions src/grammar/hive/HiveSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ loadStatement
: KW_LOAD KW_DATA KW_LOCAL? KW_INPATH StringLiteral KW_OVERWRITE? KW_INTO KW_TABLE tableOrPartition inputFileFormat?
;

dropPartitionsIgnoreClause
: KW_IGNORE KW_PROTECTION
;

replicationClause
: KW_FOR KW_METADATA? KW_REPLICATION LPAREN StringLiteral RPAREN
;
Expand Down Expand Up @@ -483,6 +487,12 @@ principalName
| KW_ROLE id_
;

principalAlterName
: KW_USER principalIdentifier
| KW_ROLE id_
| id_
;

withGrantOption
: KW_WITH KW_GRANT KW_OPTION
;
Expand Down Expand Up @@ -1337,6 +1347,7 @@ alterStatement

alterTableStatementSuffix
: alterStatementSuffixRename
| alterStatementSuffixRecoverPartitions
| alterStatementSuffixDropPartitions
| alterStatementSuffixAddPartitions
| alterStatementSuffixTouch
Expand All @@ -1349,7 +1360,7 @@ alterTableStatementSuffix
| alterStatementSuffixDropConstraint
| alterStatementSuffixAddConstraint
| alterTblPartitionStatementSuffix
| partitionSpec alterTblPartitionStatementSuffix
| partitionSpec? alterTblPartitionStatementSuffix
| alterStatementSuffixSetOwner
| alterStatementSuffixSetPartSpec
| alterStatementSuffixExecute
Expand Down Expand Up @@ -1410,7 +1421,7 @@ alterDatabaseSuffixProperties
;

alterDatabaseSuffixSetOwner
: dbName=id_ KW_SET KW_OWNER principalName
: dbName=id_ KW_SET KW_OWNER principalAlterName
;

alterDatabaseSuffixSetLocation
Expand Down Expand Up @@ -1488,8 +1499,12 @@ partitionLocation
: KW_LOCATION locn=StringLiteral
;

alterStatementSuffixRecoverPartitions
: KW_RECOVER KW_PARTITIONS
;

alterStatementSuffixDropPartitions
: KW_DROP ifExists? KW_PARTITION partitionSelectorSpec (COMMA KW_PARTITION partitionSelectorSpec)* KW_PURGE? replicationClause?
: KW_DROP ifExists? KW_PARTITION partitionSelectorSpec (COMMA KW_PARTITION partitionSelectorSpec)* dropPartitionsIgnoreClause? KW_PURGE? replicationClause?
;

alterStatementSuffixProperties
Expand Down Expand Up @@ -1616,7 +1631,7 @@ alterDataConnectorSuffixProperties
;

alterDataConnectorSuffixSetOwner
: dcName=id_ KW_SET KW_OWNER principalName
: dcName=id_ KW_SET KW_OWNER principalAlterName
;

alterDataConnectorSuffixSetUrl
Expand Down
5 changes: 4 additions & 1 deletion src/lib/hive/HiveSqlLexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit 6dad62d

Please sign in to comment.