feat: improve hive keywords rule (#154)

This commit is contained in:
Hayden 2023-09-05 14:27:21 +08:00 committed by GitHub
parent 79b66ced4f
commit ded9f28e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 12493 additions and 11060 deletions

View File

@ -92,13 +92,16 @@ KW_DATACONNECTOR : 'CONNECTOR';
KW_DATACONNECTORS : 'CONNECTORS';
KW_DATE : 'DATE';
KW_DATETIME : 'DATETIME';
KW_DAY : 'DAY' 'S'?;
KW_DAY : 'DAY';
KW_DAYS : 'DAYS';
KW_DAYOFWEEK : 'DAYOFWEEK';
KW_DBPROPERTIES : 'DBPROPERTIES';
KW_DCPROPERTIES : 'DCPROPERTIES';
KW_DDL : 'DDL';
KW_DEBUG : 'DEBUG';
KW_DECIMAL : 'DEC' 'IMAL'? | 'NUMERIC';
KW_DEC : 'DEC';
KW_DECIMAL : 'DECIMAL';
KW_NUMERIC : 'NUMERIC';
KW_DEFAULT : 'DEFAULT';
KW_DEFERRED : 'DEFERRED';
KW_DEFINED : 'DEFINED';
@ -110,7 +113,8 @@ KW_DESCRIBE : 'DESCRIBE';
KW_DETAIL : 'DETAIL';
KW_DIRECTORIES : 'DIRECTORIES';
KW_DIRECTORY : 'DIRECTORY';
KW_DISABLE : 'DISABLE' 'D'?;
KW_DISABLE : 'DISABLE';
KW_DISABLED : 'DISABLED';
KW_DISTINCT : 'DISTINCT';
KW_DISTRIBUTE : 'DISTRIBUTE';
KW_DISTRIBUTED : 'DISTRIBUTED';
@ -120,7 +124,8 @@ KW_DROP : 'DROP';
KW_DUMP : 'DUMP';
KW_ELEM_TYPE : '$ELEM$';
KW_ELSE : 'ELSE';
KW_ENABLE : 'ENABLE' 'D'?;
KW_ENABLE : 'ENABLE';
KW_ENABLED : 'ENABLED';
KW_END : 'END';
KW_ENFORCED : 'ENFORCED';
KW_ESCAPED : 'ESCAPED';
@ -161,7 +166,8 @@ KW_GROUP : 'GROUP';
KW_GROUPING : 'GROUPING';
KW_HAVING : 'HAVING';
KW_HOLD_DDLTIME : 'HOLD_DDLTIME';
KW_HOUR : 'HOUR' 'S'?;
KW_HOUR : 'HOUR';
KW_HOURS : 'HOURS';
KW_IDXPROPERTIES : 'IDXPROPERTIES';
KW_IF : 'IF';
KW_IGNORE : 'IGNORE';
@ -174,7 +180,8 @@ KW_INPATH : 'INPATH';
KW_INPUTDRIVER : 'INPUTDRIVER';
KW_INPUTFORMAT : 'INPUTFORMAT';
KW_INSERT : 'INSERT';
KW_INT : 'INT' 'EGER'?;
KW_INT : 'INT';
KW_INTEGER : 'INTEGER';
KW_INTERSECT : 'INTERSECT';
KW_INTERVAL : 'INTERVAL';
KW_INTO : 'INTO';
@ -216,15 +223,17 @@ KW_MATERIALIZED : 'MATERIALIZED';
KW_MERGE : 'MERGE';
KW_METADATA : 'METADATA';
KW_MINUS : 'MINUS';
KW_MINUTE : 'MINUTE' 'S'?;
KW_MONTH : 'MONTH' 'S'?;
KW_MINUTE : 'MINUTE';
KW_MINUTES : 'MINUTES';
KW_MONTH : 'MONTH';
KW_MONTHS : 'MONTHS';
KW_MORE : 'MORE';
KW_MOVE : 'MOVE';
KW_MSCK : 'MSCK';
KW_NONE : 'NONE';
KW_NORELY : 'NORELY';
KW_NOSCAN : 'NOSCAN';
KW_NOT : 'NOT' | '!';
KW_NOT : 'NOT';
KW_NOVALIDATE : 'NOVALIDATE';
KW_NO_DROP : 'NO_DROP';
KW_NULL : 'NULL';
@ -305,7 +314,8 @@ KW_SCHEDULED : 'SCHEDULED';
KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY';
KW_SCHEMA : 'SCHEMA';
KW_SCHEMAS : 'SCHEMAS';
KW_SECOND : 'SECOND' 'S'?;
KW_SECOND : 'SECOND';
KW_SECONDS : 'SECONDS';
KW_SELECT : 'SELECT';
KW_SEMI : 'SEMI';
KW_SERDE : 'SERDE';
@ -388,7 +398,8 @@ KW_VECTORIZATION : 'VECTORIZATION';
KW_VIEW : 'VIEW';
KW_VIEWS : 'VIEWS';
KW_WAIT : 'WAIT';
KW_WEEK : 'WEEK' 'S'?;
KW_WEEK : 'WEEK';
KW_WEEKS : 'WEEKS';
KW_WHEN : 'WHEN';
KW_WHERE : 'WHERE';
KW_WHILE : 'WHILE';
@ -398,7 +409,8 @@ KW_WITHIN : 'WITHIN';
KW_WORK : 'WORK';
KW_WORKLOAD : 'WORKLOAD';
KW_WRITE : 'WRITE';
KW_YEAR : 'YEAR' 'S'?;
KW_YEAR : 'YEAR';
KW_YEARS : 'YEARS';
KW_ZONE : 'ZONE';
// Operators
@ -430,6 +442,7 @@ STAR : '*';
MOD : '%';
DIV : 'DIV';
BITWISENOT: '!';
AMPERSAND : '&';
TILDE : '~';
BITWISEOR : '|';
@ -525,7 +538,7 @@ RegexComponent
: 'A'..'Z' | '0'..'9' | '_'
| PLUS | STAR | QUESTION | MINUS | DOT
| LPAREN | RPAREN | LSQUARE | RSQUARE | LCURLY | RCURLY
| BITWISEXOR | BITWISEOR | DOLLAR | '!'
| BITWISEXOR | BITWISEOR | DOLLAR | BITWISENOT
;
CharSetName

View File

@ -205,11 +205,11 @@ force
;
rewriteEnabled
: KW_ENABLE KW_REWRITE
: enable KW_REWRITE
;
rewriteDisabled
: KW_DISABLE KW_REWRITE
: disable KW_REWRITE
;
storedAsDirs
@ -681,7 +681,7 @@ columnNameTransformConstraint
partitionTransformType
: columnName
| (KW_YEAR | KW_MONTH | KW_DAY | KW_HOUR) LPAREN columnName RPAREN
| (year | month | day | hour) LPAREN columnName RPAREN
| (KW_TRUNCATE | KW_BUCKET) LPAREN value=Number COMMA columnName RPAREN
;
@ -822,8 +822,8 @@ enableValidateSpecification
;
enableSpecification
: KW_ENABLE
| KW_DISABLE
: enable
| disable
;
validateSpecification
@ -1021,6 +1021,7 @@ primitiveType
: KW_TINYINT
| KW_SMALLINT
| KW_INT
| KW_INTEGER
| KW_BIGINT
| KW_BOOLEAN
| KW_FLOAT
@ -1038,7 +1039,7 @@ primitiveType
//| KW_INTERVAL KW_DAY KW_TO KW_SECOND
| KW_STRING
| KW_BINARY
| KW_DECIMAL (LPAREN prec=Number (COMMA scale=Number)? RPAREN)?
| decimal (LPAREN prec=Number (COMMA scale=Number)? RPAREN)?
| (KW_VARCHAR | KW_CHAR) LPAREN length=Number RPAREN
;
@ -2170,14 +2171,14 @@ floorExpression
;
floorDateQualifiers
: KW_YEAR
: year
| KW_QUARTER
| KW_MONTH
| KW_WEEK
| KW_DAY
| KW_HOUR
| KW_MINUTE
| KW_SECOND
| month
| week
| day
| hour
| minute
| second
;
extractExpression
@ -2185,14 +2186,14 @@ extractExpression
;
timeQualifiers
: KW_YEAR
: year
| KW_QUARTER
| KW_MONTH
| KW_WEEK
| KW_DAY
| KW_HOUR
| KW_MINUTE
| KW_SECOND
| month
| week
| day
| hour
| minute
| second
;
constant
@ -2256,14 +2257,14 @@ intervalExpression
;
intervalQualifiers
: KW_YEAR KW_TO KW_MONTH
| KW_DAY KW_TO KW_SECOND
| KW_YEAR
| KW_MONTH
| KW_DAY
| KW_HOUR
| KW_MINUTE
| KW_SECOND
: year KW_TO month
| day KW_TO second
| year
| month
| day
| hour
| minute
| second
;
expression
@ -2292,6 +2293,7 @@ precedenceUnaryOperator
: PLUS
| MINUS
| TILDE
| BITWISENOT
;
precedenceUnaryPrefixExpression
@ -2524,6 +2526,7 @@ sysFuncNames
| KW_TINYINT
| KW_SMALLINT
| KW_INT
| KW_INTEGER
| KW_BIGINT
| KW_FLOAT
| KW_REAL
@ -2629,6 +2632,7 @@ nonReserved
| KW_DATABASES
| KW_DATETIME
| KW_DAY
| KW_DAYS
| KW_DAYOFWEEK
| KW_DBPROPERTIES
| KW_DCPROPERTIES
@ -2643,12 +2647,14 @@ nonReserved
| KW_DIRECTORIES
| KW_DIRECTORY
| KW_DISABLE
| KW_DISABLED
| KW_DISTRIBUTE
| KW_DISTRIBUTED
| KW_DO
| KW_DUMP
| KW_ELEM_TYPE
| KW_ENABLE
| KW_ENABLED
| KW_ENFORCED
| KW_ESCAPED
| KW_EVERY
@ -2668,6 +2674,7 @@ nonReserved
| KW_FUNCTIONS
| KW_HOLD_DDLTIME
| KW_HOUR
| KW_HOURS
| KW_IDXPROPERTIES
| KW_IGNORE
| KW_INDEX
@ -2702,7 +2709,9 @@ nonReserved
| KW_MATERIALIZED
| KW_METADATA
| KW_MINUTE
| KW_MINUTES
| KW_MONTH
| KW_MONTHS
| KW_MOVE
| KW_MSCK
| KW_NORELY
@ -2756,6 +2765,7 @@ nonReserved
| KW_SCHEMA
| KW_SCHEMAS
| KW_SECOND
| KW_SECONDS
| KW_SEMI
| KW_SERDE
| KW_SERDEPROPERTIES
@ -2812,12 +2822,14 @@ nonReserved
| KW_VIEWS
| KW_WAIT
| KW_WEEK
| KW_WEEKS
| KW_WHILE
| KW_WITHIN
| KW_WORK
| KW_WORKLOAD
| KW_WRITE
| KW_YEAR
| KW_YEARS
| KW_ZONE
;
@ -2837,6 +2849,7 @@ sql11ReservedKeywordsUsedAsFunctionName
| KW_GROUPING
| KW_IF
| KW_INT
| KW_INTEGER
| KW_MAP
| KW_REAL
| KW_SMALLINT
@ -2937,20 +2950,63 @@ activate
enable
: KW_ENABLE
| KW_ENABLED
;
disable
: KW_DISABLE
| KW_DISABLED
;
unmanaged
: KW_UNMANAGED
;
year
: KW_YEAR
| KW_YEARS
;
month
: KW_MONTH
| KW_MONTHS
;
week
: KW_WEEK
| KW_WEEKS
;
day
: KW_DAY
| KW_DAYS
;
hour
: KW_HOUR
| KW_HOURS
;
minute
: KW_MINUTE
| KW_MINUTES
;
second
: KW_SECOND
| KW_SECONDS
;
decimal
: KW_DEC
| KW_DECIMAL
| KW_NUMERIC
;
alterResourcePlanStatement
: KW_ALTER KW_RESOURCE KW_PLAN name=id_ (
KW_VALIDATE
| KW_DISABLE
| disable
| KW_SET rpAssignList
| KW_UNSET rpUnassignList
| KW_RENAME KW_TO newName=id_
@ -2962,7 +3018,7 @@ alterResourcePlanStatement
/** It might make sense to make this more generic, if something else could be enabled/disabled.
For now, it's only used for WM. Translate into another form of an alter statement. */
globalWmStatement
: (KW_ENABLE | KW_DISABLE) KW_WORKLOAD KW_MANAGEMENT
: (enable | disable) KW_WORKLOAD KW_MANAGEMENT
;
replaceResourcePlanStatement

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

@ -481,6 +481,14 @@ import { ActivateContext } from "./HiveSqlParser";
import { EnableContext } from "./HiveSqlParser";
import { DisableContext } from "./HiveSqlParser";
import { UnmanagedContext } from "./HiveSqlParser";
import { YearContext } from "./HiveSqlParser";
import { MonthContext } from "./HiveSqlParser";
import { WeekContext } from "./HiveSqlParser";
import { DayContext } from "./HiveSqlParser";
import { HourContext } from "./HiveSqlParser";
import { MinuteContext } from "./HiveSqlParser";
import { SecondContext } from "./HiveSqlParser";
import { DecimalContext } from "./HiveSqlParser";
import { AlterResourcePlanStatementContext } from "./HiveSqlParser";
import { GlobalWmStatementContext } from "./HiveSqlParser";
import { ReplaceResourcePlanStatementContext } from "./HiveSqlParser";
@ -5771,6 +5779,94 @@ export interface HiveSqlParserListener extends ParseTreeListener {
*/
exitUnmanaged?: (ctx: UnmanagedContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.year`.
* @param ctx the parse tree
*/
enterYear?: (ctx: YearContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.year`.
* @param ctx the parse tree
*/
exitYear?: (ctx: YearContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.month`.
* @param ctx the parse tree
*/
enterMonth?: (ctx: MonthContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.month`.
* @param ctx the parse tree
*/
exitMonth?: (ctx: MonthContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.week`.
* @param ctx the parse tree
*/
enterWeek?: (ctx: WeekContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.week`.
* @param ctx the parse tree
*/
exitWeek?: (ctx: WeekContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.day`.
* @param ctx the parse tree
*/
enterDay?: (ctx: DayContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.day`.
* @param ctx the parse tree
*/
exitDay?: (ctx: DayContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.hour`.
* @param ctx the parse tree
*/
enterHour?: (ctx: HourContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.hour`.
* @param ctx the parse tree
*/
exitHour?: (ctx: HourContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.minute`.
* @param ctx the parse tree
*/
enterMinute?: (ctx: MinuteContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.minute`.
* @param ctx the parse tree
*/
exitMinute?: (ctx: MinuteContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.second`.
* @param ctx the parse tree
*/
enterSecond?: (ctx: SecondContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.second`.
* @param ctx the parse tree
*/
exitSecond?: (ctx: SecondContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.decimal`.
* @param ctx the parse tree
*/
enterDecimal?: (ctx: DecimalContext) => void;
/**
* Exit a parse tree produced by `HiveSqlParser.decimal`.
* @param ctx the parse tree
*/
exitDecimal?: (ctx: DecimalContext) => void;
/**
* Enter a parse tree produced by `HiveSqlParser.alterResourcePlanStatement`.
* @param ctx the parse tree

View File

@ -481,6 +481,14 @@ import { ActivateContext } from "./HiveSqlParser";
import { EnableContext } from "./HiveSqlParser";
import { DisableContext } from "./HiveSqlParser";
import { UnmanagedContext } from "./HiveSqlParser";
import { YearContext } from "./HiveSqlParser";
import { MonthContext } from "./HiveSqlParser";
import { WeekContext } from "./HiveSqlParser";
import { DayContext } from "./HiveSqlParser";
import { HourContext } from "./HiveSqlParser";
import { MinuteContext } from "./HiveSqlParser";
import { SecondContext } from "./HiveSqlParser";
import { DecimalContext } from "./HiveSqlParser";
import { AlterResourcePlanStatementContext } from "./HiveSqlParser";
import { GlobalWmStatementContext } from "./HiveSqlParser";
import { ReplaceResourcePlanStatementContext } from "./HiveSqlParser";
@ -3862,6 +3870,62 @@ export interface HiveSqlParserVisitor<Result> extends ParseTreeVisitor<Result> {
*/
visitUnmanaged?: (ctx: UnmanagedContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.year`.
* @param ctx the parse tree
* @return the visitor result
*/
visitYear?: (ctx: YearContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.month`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMonth?: (ctx: MonthContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.week`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWeek?: (ctx: WeekContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.day`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDay?: (ctx: DayContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.hour`.
* @param ctx the parse tree
* @return the visitor result
*/
visitHour?: (ctx: HourContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.minute`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMinute?: (ctx: MinuteContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.second`.
* @param ctx the parse tree
* @return the visitor result
*/
visitSecond?: (ctx: SecondContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.decimal`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDecimal?: (ctx: DecimalContext) => Result;
/**
* Visit a parse tree produced by `HiveSqlParser.alterResourcePlanStatement`.
* @param ctx the parse tree