check alter sql and syntax (#156)

* 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 <>
This commit is contained in:
XCynthia
2023-09-06 11:46:46 +08:00
committed by GitHub
parent ded9f28e36
commit 6dad62ddf4
17 changed files with 12348 additions and 11838 deletions

View File

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

View File

@ -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
;
@ -483,6 +487,12 @@ principalName
| KW_ROLE id_
;
principalAlterName
: KW_USER principalIdentifier
| KW_ROLE id_
| id_
;
withGrantOption
: KW_WITH KW_GRANT KW_OPTION
;
@ -1337,6 +1347,7 @@ alterStatement
alterTableStatementSuffix
: alterStatementSuffixRename
| alterStatementSuffixRecoverPartitions
| alterStatementSuffixDropPartitions
| alterStatementSuffixAddPartitions
| alterStatementSuffixTouch
@ -1349,7 +1360,7 @@ alterTableStatementSuffix
| alterStatementSuffixDropConstraint
| alterStatementSuffixAddConstraint
| alterTblPartitionStatementSuffix
| partitionSpec alterTblPartitionStatementSuffix
| partitionSpec? alterTblPartitionStatementSuffix
| alterStatementSuffixSetOwner
| alterStatementSuffixSetPartSpec
| alterStatementSuffixExecute
@ -1410,7 +1421,7 @@ alterDatabaseSuffixProperties
;
alterDatabaseSuffixSetOwner
: dbName=id_ KW_SET KW_OWNER principalName
: dbName=id_ KW_SET KW_OWNER principalAlterName
;
alterDatabaseSuffixSetLocation
@ -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
@ -1616,7 +1631,7 @@ alterDataConnectorSuffixProperties
;
alterDataConnectorSuffixSetOwner
: dcName=id_ KW_SET KW_OWNER principalName
: dcName=id_ KW_SET KW_OWNER principalAlterName
;
alterDataConnectorSuffixSetUrl

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/xuxiaoqi/Documents/dt-sql-parser-copy/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
@ -11,6 +11,7 @@ import { VectorizationOnlyContext } from "./HiveSqlParser";
import { VectorizatonDetailContext } from "./HiveSqlParser";
import { ExecStatementContext } from "./HiveSqlParser";
import { LoadStatementContext } from "./HiveSqlParser";
import { DropPartitionsIgnoreClauseContext } from "./HiveSqlParser";
import { ReplicationClauseContext } from "./HiveSqlParser";
import { ExportStatementContext } from "./HiveSqlParser";
import { ImportStatementContext } from "./HiveSqlParser";
@ -77,6 +78,7 @@ import { PrivlegeDefContext } from "./HiveSqlParser";
import { PrivilegeTypeContext } from "./HiveSqlParser";
import { PrincipalSpecificationContext } from "./HiveSqlParser";
import { PrincipalNameContext } from "./HiveSqlParser";
import { PrincipalAlterNameContext } from "./HiveSqlParser";
import { WithGrantOptionContext } from "./HiveSqlParser";
import { GrantOptionForContext } from "./HiveSqlParser";
import { AdminOptionForContext } from "./HiveSqlParser";
@ -268,6 +270,7 @@ import { AlterStatementSuffixTouchContext } from "./HiveSqlParser";
import { AlterStatementSuffixArchiveContext } from "./HiveSqlParser";
import { AlterStatementSuffixUnArchiveContext } from "./HiveSqlParser";
import { PartitionLocationContext } from "./HiveSqlParser";
import { AlterStatementSuffixRecoverPartitionsContext } from "./HiveSqlParser";
import { AlterStatementSuffixDropPartitionsContext } from "./HiveSqlParser";
import { AlterStatementSuffixPropertiesContext } from "./HiveSqlParser";
import { AlterViewSuffixPropertiesContext } from "./HiveSqlParser";
@ -609,6 +612,17 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitLoadStatement?: (ctx: LoadStatementContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.dropPartitionsIgnoreClause`.
* @param ctx the parse tree
*/
enterDropPartitionsIgnoreClause?: (ctx: DropPartitionsIgnoreClauseContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.dropPartitionsIgnoreClause`.
* @param ctx the parse tree
*/
exitDropPartitionsIgnoreClause?: (ctx: DropPartitionsIgnoreClauseContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.replicationClause`.
* @param ctx the parse tree
@ -1335,6 +1349,17 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitPrincipalName?: (ctx: PrincipalNameContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.principalAlterName`.
* @param ctx the parse tree
*/
enterPrincipalAlterName?: (ctx: PrincipalAlterNameContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.principalAlterName`.
* @param ctx the parse tree
*/
exitPrincipalAlterName?: (ctx: PrincipalAlterNameContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.withGrantOption`.
* @param ctx the parse tree
@ -3436,6 +3461,17 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitPartitionLocation?: (ctx: PartitionLocationContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.alterStatementSuffixRecoverPartitions`.
* @param ctx the parse tree
*/
enterAlterStatementSuffixRecoverPartitions?: (ctx: AlterStatementSuffixRecoverPartitionsContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.alterStatementSuffixRecoverPartitions`.
* @param ctx the parse tree
*/
exitAlterStatementSuffixRecoverPartitions?: (ctx: AlterStatementSuffixRecoverPartitionsContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.alterStatementSuffixDropPartitions`.
* @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from /Users/xuxiaoqi/Documents/dt-sql-parser-copy/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
@ -11,6 +11,7 @@ import { VectorizationOnlyContext } from "./HiveSqlParser";
import { VectorizatonDetailContext } from "./HiveSqlParser";
import { ExecStatementContext } from "./HiveSqlParser";
import { LoadStatementContext } from "./HiveSqlParser";
import { DropPartitionsIgnoreClauseContext } from "./HiveSqlParser";
import { ReplicationClauseContext } from "./HiveSqlParser";
import { ExportStatementContext } from "./HiveSqlParser";
import { ImportStatementContext } from "./HiveSqlParser";
@ -77,6 +78,7 @@ import { PrivlegeDefContext } from "./HiveSqlParser";
import { PrivilegeTypeContext } from "./HiveSqlParser";
import { PrincipalSpecificationContext } from "./HiveSqlParser";
import { PrincipalNameContext } from "./HiveSqlParser";
import { PrincipalAlterNameContext } from "./HiveSqlParser";
import { WithGrantOptionContext } from "./HiveSqlParser";
import { GrantOptionForContext } from "./HiveSqlParser";
import { AdminOptionForContext } from "./HiveSqlParser";
@ -268,6 +270,7 @@ import { AlterStatementSuffixTouchContext } from "./HiveSqlParser";
import { AlterStatementSuffixArchiveContext } from "./HiveSqlParser";
import { AlterStatementSuffixUnArchiveContext } from "./HiveSqlParser";
import { PartitionLocationContext } from "./HiveSqlParser";
import { AlterStatementSuffixRecoverPartitionsContext } from "./HiveSqlParser";
import { AlterStatementSuffixDropPartitionsContext } from "./HiveSqlParser";
import { AlterStatementSuffixPropertiesContext } from "./HiveSqlParser";
import { AlterViewSuffixPropertiesContext } from "./HiveSqlParser";
@ -580,6 +583,13 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitLoadStatement?: (ctx: LoadStatementContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.dropPartitionsIgnoreClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDropPartitionsIgnoreClause?: (ctx: DropPartitionsIgnoreClauseContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.replicationClause`.
* @param ctx the parse tree
@ -1042,6 +1052,13 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitPrincipalName?: (ctx: PrincipalNameContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.principalAlterName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPrincipalAlterName?: (ctx: PrincipalAlterNameContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.withGrantOption`.
* @param ctx the parse tree
@ -2379,6 +2396,13 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitPartitionLocation?: (ctx: PartitionLocationContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.alterStatementSuffixRecoverPartitions`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAlterStatementSuffixRecoverPartitions?: (ctx: AlterStatementSuffixRecoverPartitionsContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.alterStatementSuffixDropPartitions`.
* @param ctx the parse tree