feat(flink): support insert multipe tables statement for FlinkSQL 1.15(#104)

* feat(flink): support insert multipe tables statement for FlinkSQL 1.15

* test: recover jest.config info

* fix(flink): correct typo

* fix(flinksql): resolve conflicts
This commit is contained in:
mumiao 2023-05-23 14:40:52 +08:00 committed by GitHub
parent 4b824fb500
commit c409b80ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2621 additions and 2462 deletions

View File

@ -347,7 +347,8 @@ dropFunction
// Insert statements // Insert statements
insertStatement insertStatement
: (KW_EXECUTE? insertSimpleStatement) | (KW_EXECUTE insertMulStatement) : (KW_EXECUTE? insertSimpleStatement)
| insertMulStatementCompatibility | (KW_EXECUTE insertMulStatement)
; ;
insertSimpleStatement insertSimpleStatement
@ -372,6 +373,10 @@ valuesRowDefinition
RR_BRACKET RR_BRACKET
; ;
insertMulStatementCompatibility
: KW_BEGIN KW_STATEMENT KW_SET SEMICOLON (insertSimpleStatement SEMICOLON)+ KW_END
;
insertMulStatement insertMulStatement
: KW_STATEMENT KW_SET KW_BEGIN (insertSimpleStatement SEMICOLON)+ KW_END : KW_STATEMENT KW_SET KW_BEGIN (insertSimpleStatement SEMICOLON)+ KW_END
; ;

View File

@ -1,4 +1,4 @@
// Generated from /Users/mortalYoung/Projects/dt-sql-parser/src/grammar/flinksql/FlinkSqlLexer.g4 by ANTLR 4.12.0 // Generated from /Users/zhenglin/Documents/parser/dt-sql-parser/src/grammar/flinksql/FlinkSqlLexer.g4 by ANTLR 4.12.0
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
import { import {
ATN, ATN,

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/mortalYoung/Projects/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0 // Generated from /Users/zhenglin/Documents/parser/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeListener} from "antlr4"; import {ParseTreeListener} from "antlr4";
@ -81,6 +81,7 @@ import { InsertSimpleStatementContext } from "./FlinkSqlParser";
import { InsertPartitionDefinitionContext } from "./FlinkSqlParser"; import { InsertPartitionDefinitionContext } from "./FlinkSqlParser";
import { ValuesDefinitionContext } from "./FlinkSqlParser"; import { ValuesDefinitionContext } from "./FlinkSqlParser";
import { ValuesRowDefinitionContext } from "./FlinkSqlParser"; import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
import { InsertMulStatementCompatibilityContext } from "./FlinkSqlParser";
import { InsertMulStatementContext } from "./FlinkSqlParser"; import { InsertMulStatementContext } from "./FlinkSqlParser";
import { QueryStatementContext } from "./FlinkSqlParser"; import { QueryStatementContext } from "./FlinkSqlParser";
import { ValuesCaluseContext } from "./FlinkSqlParser"; import { ValuesCaluseContext } from "./FlinkSqlParser";
@ -993,6 +994,16 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitValuesRowDefinition?: (ctx: ValuesRowDefinitionContext) => void; exitValuesRowDefinition?: (ctx: ValuesRowDefinitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.insertMulStatementCompatibility`.
* @param ctx the parse tree
*/
enterInsertMulStatementCompatibility?: (ctx: InsertMulStatementCompatibilityContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.insertMulStatementCompatibility`.
* @param ctx the parse tree
*/
exitInsertMulStatementCompatibility?: (ctx: InsertMulStatementCompatibilityContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.insertMulStatement`. * Enter a parse tree produced by `FlinkSqlParser.insertMulStatement`.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from /Users/mortalYoung/Projects/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0 // Generated from /Users/zhenglin/Documents/parser/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeVisitor} from 'antlr4'; import {ParseTreeVisitor} from 'antlr4';
@ -81,6 +81,7 @@ import { InsertSimpleStatementContext } from "./FlinkSqlParser";
import { InsertPartitionDefinitionContext } from "./FlinkSqlParser"; import { InsertPartitionDefinitionContext } from "./FlinkSqlParser";
import { ValuesDefinitionContext } from "./FlinkSqlParser"; import { ValuesDefinitionContext } from "./FlinkSqlParser";
import { ValuesRowDefinitionContext } from "./FlinkSqlParser"; import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
import { InsertMulStatementCompatibilityContext } from "./FlinkSqlParser";
import { InsertMulStatementContext } from "./FlinkSqlParser"; import { InsertMulStatementContext } from "./FlinkSqlParser";
import { QueryStatementContext } from "./FlinkSqlParser"; import { QueryStatementContext } from "./FlinkSqlParser";
import { ValuesCaluseContext } from "./FlinkSqlParser"; import { ValuesCaluseContext } from "./FlinkSqlParser";
@ -682,6 +683,12 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitValuesRowDefinition?: (ctx: ValuesRowDefinitionContext) => Result; visitValuesRowDefinition?: (ctx: ValuesRowDefinitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.insertMulStatementCompatibility`.
* @param ctx the parse tree
* @return the visitor result
*/
visitInsertMulStatementCompatibility?: (ctx: InsertMulStatementCompatibilityContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.insertMulStatement`. * Visit a parse tree produced by `FlinkSqlParser.insertMulStatement`.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -10,7 +10,7 @@ export const readSQL = (dirname: string, fileName: string) => {
const char = content[index]; const char = content[index];
tmp += char; tmp += char;
const isMulti = tmp.includes('EXECUTE STATEMENT SET'); const isMulti = tmp.includes('EXECUTE STATEMENT SET') || tmp.includes('BEGIN STATEMENT SET;');
if (!isMulti) { if (!isMulti) {
// 非批量的先简单按照分号切割 // 非批量的先简单按照分号切割

View File

@ -1,3 +1,5 @@
-- FlinkSQL 1.16insert multiple table statement
EXECUTE STATEMENT SET EXECUTE STATEMENT SET
BEGIN BEGIN
INSERT INTO country_page_view INSERT INTO country_page_view
@ -8,4 +10,13 @@ VALUES ('Chinese', 'mumiao', 18),
('Amercian', 'georage', 22); ('Amercian', 'georage', 22);
END; END;
-- FlinkSQL 1.15insert multiple table statement
BEGIN STATEMENT SET;
INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),
('Amercian', 'georage', 22);
INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),
('Amercian', 'georage', 22);
END;