feat: replace fliePath with slashText to resolve conflict between filePath and arithmetic (#112)

This commit is contained in:
Hayden 2023-05-30 10:19:13 +08:00 committed by GitHub
parent 76d7ee5e70
commit 793ff6ef0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 3882 additions and 3714 deletions

View File

@ -442,9 +442,9 @@ REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ EXPONENT_NUM_PART;
BIT_STRING: BIT_STRING_L;
ID_LITERAL: ID_LITERAL_FRAG;
FILE_PATH: FILE_PATH_STRING;
SLASH_TEXT: SLASH_TEXT_FRAG;
fragment FILE_PATH_STRING: ([/\\] (~([/\\ ]))*)+;
fragment SLASH_TEXT_FRAG: [/\\] (~([/\\ ] | '(' | ')' | ';'))*;
fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL_FRAG: [A-Z_0-9a-z]*?[A-Z_a-z]+?[A-Z_0-9a-z]*;

View File

@ -88,11 +88,15 @@ jarStatememt
// 数栈平台自研的添加文件语法
dtAddStatement
: KW_ADD KW_JAR KW_WITH FILE_PATH (KW_AS uid)?
| KW_ADD KW_FILE KW_WITH FILE_PATH (KW_AS uid)? (KW_RENAME uid)?
| KW_ADD (KW_PYTHON_FILES | KW_PYTHON_REQUIREMENTS | KW_PYTHON_DEPENDENCIES | KW_PYTHON_JAR | KW_PYTHON_ARCHIVES) KW_WITH FILE_PATH KW_RENAME uid
| KW_ADD KW_PYTHON_PARAMETER FILE_PATH
| KW_ADD KW_ENGINE KW_FILE KW_WITH FILE_PATH KW_RENAME uid KW_KEY uid
: KW_ADD KW_JAR KW_WITH dtFilePath (KW_AS uid)?
| KW_ADD KW_FILE KW_WITH dtFilePath (KW_AS uid)? (KW_RENAME uid)?
| KW_ADD (KW_PYTHON_FILES | KW_PYTHON_REQUIREMENTS | KW_PYTHON_DEPENDENCIES | KW_PYTHON_JAR | KW_PYTHON_ARCHIVES) KW_WITH dtFilePath KW_RENAME uid
| KW_ADD KW_PYTHON_PARAMETER dtFilePath
| KW_ADD KW_ENGINE KW_FILE KW_WITH dtFilePath KW_RENAME uid KW_KEY uid
;
dtFilePath
: SLASH_TEXT+
;
// Create statements
@ -696,6 +700,7 @@ valueExpression
| left=valueExpression operator='^' right=valueExpression #arithmeticBinary
| left=valueExpression operator='|' right=valueExpression #arithmeticBinary
| left=valueExpression comparisonOperator right=valueExpression #comparison
| left=valueExpression right=SLASH_TEXT #arithmeticBinaryAlternate
;
primaryExpression

File diff suppressed because one or more lines are too long

View File

@ -407,7 +407,7 @@ DIG_LITERAL=406
REAL_LITERAL=407
BIT_STRING=408
ID_LITERAL=409
FILE_PATH=410
SLASH_TEXT=410
'ADD'=4
'ADMIN'=5
'AFTER'=6

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -407,7 +407,7 @@ DIG_LITERAL=406
REAL_LITERAL=407
BIT_STRING=408
ID_LITERAL=409
FILE_PATH=410
SLASH_TEXT=410
'ADD'=4
'ADMIN'=5
'AFTER'=6

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@ import { SetStatememtContext } from "./FlinkSqlParser";
import { ResetStatememtContext } from "./FlinkSqlParser";
import { JarStatememtContext } from "./FlinkSqlParser";
import { DtAddStatementContext } from "./FlinkSqlParser";
import { DtFilePathContext } from "./FlinkSqlParser";
import { CreateTableContext } from "./FlinkSqlParser";
import { SimpleCreateTableContext } from "./FlinkSqlParser";
import { CreateTableAsSelectContext } from "./FlinkSqlParser";
@ -144,6 +145,7 @@ import { PredicateContext } from "./FlinkSqlParser";
import { LikePredicateContext } from "./FlinkSqlParser";
import { ValueExpressionDefaultContext } from "./FlinkSqlParser";
import { ComparisonContext } from "./FlinkSqlParser";
import { ArithmeticBinaryAlternateContext } from "./FlinkSqlParser";
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
import { DereferenceContext } from "./FlinkSqlParser";
@ -416,6 +418,16 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitDtAddStatement?: (ctx: DtAddStatementContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.dtFilePath`.
* @param ctx the parse tree
*/
enterDtFilePath?: (ctx: DtFilePathContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.dtFilePath`.
* @param ctx the parse tree
*/
exitDtFilePath?: (ctx: DtFilePathContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.createTable`.
* @param ctx the parse tree
@ -1644,6 +1656,18 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitComparison?: (ctx: ComparisonContext) => void;
/**
* Enter a parse tree produced by the `arithmeticBinaryAlternate`
* labeled alternative in `FlinkSqlParser.valueExpression`.
* @param ctx the parse tree
*/
enterArithmeticBinaryAlternate?: (ctx: ArithmeticBinaryAlternateContext) => void;
/**
* Exit a parse tree produced by the `arithmeticBinaryAlternate`
* labeled alternative in `FlinkSqlParser.valueExpression`.
* @param ctx the parse tree
*/
exitArithmeticBinaryAlternate?: (ctx: ArithmeticBinaryAlternateContext) => void;
/**
* Enter a parse tree produced by the `arithmeticBinary`
* labeled alternative in `FlinkSqlParser.valueExpression`.

View File

@ -23,6 +23,7 @@ import { SetStatememtContext } from "./FlinkSqlParser";
import { ResetStatememtContext } from "./FlinkSqlParser";
import { JarStatememtContext } from "./FlinkSqlParser";
import { DtAddStatementContext } from "./FlinkSqlParser";
import { DtFilePathContext } from "./FlinkSqlParser";
import { CreateTableContext } from "./FlinkSqlParser";
import { SimpleCreateTableContext } from "./FlinkSqlParser";
import { CreateTableAsSelectContext } from "./FlinkSqlParser";
@ -144,6 +145,7 @@ import { PredicateContext } from "./FlinkSqlParser";
import { LikePredicateContext } from "./FlinkSqlParser";
import { ValueExpressionDefaultContext } from "./FlinkSqlParser";
import { ComparisonContext } from "./FlinkSqlParser";
import { ArithmeticBinaryAlternateContext } from "./FlinkSqlParser";
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
import { DereferenceContext } from "./FlinkSqlParser";
@ -339,6 +341,12 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitDtAddStatement?: (ctx: DtAddStatementContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.dtFilePath`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDtFilePath?: (ctx: DtFilePathContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.createTable`.
* @param ctx the parse tree
@ -1074,6 +1082,13 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitComparison?: (ctx: ComparisonContext) => Result;
/**
* Visit a parse tree produced by the `arithmeticBinaryAlternate`
* labeled alternative in `FlinkSqlParser.valueExpression`.
* @param ctx the parse tree
* @return the visitor result
*/
visitArithmeticBinaryAlternate?: (ctx: ArithmeticBinaryAlternateContext) => Result;
/**
* Visit a parse tree produced by the `arithmeticBinary`
* labeled alternative in `FlinkSqlParser.valueExpression`.

View File

@ -431,14 +431,14 @@ BEGIN STATEMENT SET;
INSERT INTO avg_request_size_1m SELECT
window_start,
window_end,
total_size / num_requests AS avg_size
total_size/num_requests AS avg_size
FROM server_logs_window_1m;
-- 写入结果到5min窗口粒度结果表
INSERT INTO avg_request_size_5m SELECT
window_start,
window_end,
total_size / num_requests AS avg_size
total_size/num_requests AS avg_size
FROM server_logs_window_5m;
END;