* fix: #213 use uid to replace SLASH_TEXT in dtFilePath rule * test: #213 flinksql syntax expression --------- Co-authored-by: liuyi <liuyi@dtstack.com>
This commit is contained in:
parent
00b66ccf44
commit
6bbcb3c8d3
@ -583,9 +583,7 @@ REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
|
|||||||
| DEC_DIGIT+ EXPONENT_NUM_PART;
|
| DEC_DIGIT+ EXPONENT_NUM_PART;
|
||||||
BIT_STRING: BIT_STRING_L;
|
BIT_STRING: BIT_STRING_L;
|
||||||
ID_LITERAL: ID_LITERAL_FRAG;
|
ID_LITERAL: ID_LITERAL_FRAG;
|
||||||
SLASH_TEXT: SLASH_TEXT_FRAG;
|
|
||||||
|
|
||||||
fragment SLASH_TEXT_FRAG: [/\\] (~([/\\ ] | '(' | ')' | ';'))*;
|
|
||||||
fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
|
fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
|
||||||
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
|
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]*;
|
fragment ID_LITERAL_FRAG: [A-Z_0-9a-z]*?[A-Z_a-z]+?[A-Z_0-9a-z]*;
|
||||||
|
@ -101,7 +101,7 @@ dtAddStatement
|
|||||||
;
|
;
|
||||||
|
|
||||||
dtFilePath
|
dtFilePath
|
||||||
: SLASH_TEXT+
|
: (SLASH_SIGN? uid)+
|
||||||
;
|
;
|
||||||
|
|
||||||
// Create statements
|
// Create statements
|
||||||
@ -698,7 +698,6 @@ valueExpression
|
|||||||
| left=valueExpression operator=BIT_XOR_OP right=valueExpression #arithmeticBinary
|
| left=valueExpression operator=BIT_XOR_OP right=valueExpression #arithmeticBinary
|
||||||
| left=valueExpression operator=BIT_OR_OP right=valueExpression #arithmeticBinary
|
| left=valueExpression operator=BIT_OR_OP right=valueExpression #arithmeticBinary
|
||||||
| left=valueExpression comparisonOperator right=valueExpression #comparison
|
| left=valueExpression comparisonOperator right=valueExpression #comparison
|
||||||
| left=valueExpression right=SLASH_TEXT #arithmeticBinaryAlternate
|
|
||||||
;
|
;
|
||||||
|
|
||||||
primaryExpression
|
primaryExpression
|
||||||
|
File diff suppressed because one or more lines are too long
@ -539,7 +539,6 @@ DIG_LITERAL=538
|
|||||||
REAL_LITERAL=539
|
REAL_LITERAL=539
|
||||||
BIT_STRING=540
|
BIT_STRING=540
|
||||||
ID_LITERAL=541
|
ID_LITERAL=541
|
||||||
SLASH_TEXT=542
|
|
||||||
'ABS'=4
|
'ABS'=4
|
||||||
'ALL'=5
|
'ALL'=5
|
||||||
'ALLOCATE'=6
|
'ALLOCATE'=6
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -539,7 +539,6 @@ DIG_LITERAL=538
|
|||||||
REAL_LITERAL=539
|
REAL_LITERAL=539
|
||||||
BIT_STRING=540
|
BIT_STRING=540
|
||||||
ID_LITERAL=541
|
ID_LITERAL=541
|
||||||
SLASH_TEXT=542
|
|
||||||
'ABS'=4
|
'ABS'=4
|
||||||
'ALL'=5
|
'ALL'=5
|
||||||
'ALLOCATE'=6
|
'ALLOCATE'=6
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
|
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
|
||||||
@ -10,7 +10,6 @@ import { ValueExpressionDefaultContext } from "./FlinkSqlParser";
|
|||||||
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
|
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
|
||||||
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
|
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
|
||||||
import { ComparisonContext } from "./FlinkSqlParser";
|
import { ComparisonContext } from "./FlinkSqlParser";
|
||||||
import { ArithmeticBinaryAlternateContext } from "./FlinkSqlParser";
|
|
||||||
import { SearchedCaseContext } from "./FlinkSqlParser";
|
import { SearchedCaseContext } from "./FlinkSqlParser";
|
||||||
import { SimpleCaseContext } from "./FlinkSqlParser";
|
import { SimpleCaseContext } from "./FlinkSqlParser";
|
||||||
import { CastContext } from "./FlinkSqlParser";
|
import { CastContext } from "./FlinkSqlParser";
|
||||||
@ -321,19 +320,6 @@ export interface FlinkSqlParserListener extends ParseTreeListener {
|
|||||||
*/
|
*/
|
||||||
exitComparison?: (ctx: ComparisonContext) => void;
|
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 `searchedCase`
|
* Enter a parse tree produced by the `searchedCase`
|
||||||
* labeled alternative in `FlinkSqlParser.primaryExpression`.
|
* labeled alternative in `FlinkSqlParser.primaryExpression`.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
// Generated from /Users/liuyi/Desktop/Projects/dtstack/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
|
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
|
||||||
@ -10,7 +10,6 @@ import { ValueExpressionDefaultContext } from "./FlinkSqlParser";
|
|||||||
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
|
import { ArithmeticUnaryContext } from "./FlinkSqlParser";
|
||||||
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
|
import { ArithmeticBinaryContext } from "./FlinkSqlParser";
|
||||||
import { ComparisonContext } from "./FlinkSqlParser";
|
import { ComparisonContext } from "./FlinkSqlParser";
|
||||||
import { ArithmeticBinaryAlternateContext } from "./FlinkSqlParser";
|
|
||||||
import { SearchedCaseContext } from "./FlinkSqlParser";
|
import { SearchedCaseContext } from "./FlinkSqlParser";
|
||||||
import { SimpleCaseContext } from "./FlinkSqlParser";
|
import { SimpleCaseContext } from "./FlinkSqlParser";
|
||||||
import { CastContext } from "./FlinkSqlParser";
|
import { CastContext } from "./FlinkSqlParser";
|
||||||
@ -289,14 +288,6 @@ export interface FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Result>
|
|||||||
*/
|
*/
|
||||||
visitComparison?: (ctx: ComparisonContext) => 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 `searchedCase`
|
* Visit a parse tree produced by the `searchedCase`
|
||||||
* labeled alternative in `FlinkSqlParser.primaryExpression`.
|
* labeled alternative in `FlinkSqlParser.primaryExpression`.
|
||||||
|
16
test/parser/flinksql/syntax/expressionStatement.test.ts
Normal file
16
test/parser/flinksql/syntax/expressionStatement.test.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import FlinkSQL from '../../../../src/parser/flinksql';
|
||||||
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
|
const features = {
|
||||||
|
expression: readSQL(__dirname, 'expression.sql'),
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('FlinkSQL Expression Syntax Tests', () => {
|
||||||
|
const parser = new FlinkSQL();
|
||||||
|
|
||||||
|
features.expression.forEach((sql) => {
|
||||||
|
it(sql, () => {
|
||||||
|
expect(parser.validate(sql).length).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -16,7 +16,7 @@ ADD PYTHON_DEPENDENCIES WITH /dependencies.txt RENAME dependencies.txt;
|
|||||||
|
|
||||||
ADD PYTHON_JAR WITH /python_jar.jar RENAME py_jar.jar;
|
ADD PYTHON_JAR WITH /python_jar.jar RENAME py_jar.jar;
|
||||||
|
|
||||||
ADD PYTHON_PARAMETER /parameter.py;
|
ADD PYTHON_PARAMETER my_parameter.py;
|
||||||
|
|
||||||
ADD PYTHON_ARCHIVES WITH /archives.py RENAME archive.tx;
|
ADD PYTHON_ARCHIVES WITH /archives.py RENAME archive.tx;
|
||||||
|
|
||||||
|
8
test/parser/flinksql/syntax/fixtures/expression.sql
Normal file
8
test/parser/flinksql/syntax/fixtures/expression.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
SELECT FROM_UNIXTIME(t1.create_time / 1000, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000 * 1, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000 + 1, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000 - 1, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000 % 2, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
||||||
|
SELECT FROM_UNIXTIME(t1.create_time/1000 / 1, 'yyyyMMddHHmmss') AS create_time FROM t1;
|
Loading…
Reference in New Issue
Block a user