feat: improve flinksql createStatement (#91)
* feat: improve flinksql createStatement * feat: complete CREATE syntax unit tests * feat: complete CREATA TABLE syntax tests * feat: develop flinkSQL grammar * feat: improve tableConstraint * fix: convert TIMESTAMP_LTZ * test: improve tests * feat: build new flinksql parser and lexer * test: add CREATE TEMPLATE TABLE test
This commit is contained in:
@ -79,6 +79,7 @@ FIRST: 'FIRST';
|
||||
AFTER: 'AFTER';
|
||||
LAST: 'LAST';
|
||||
WITH: 'WITH';
|
||||
WITHOUT: 'WITHOUT';
|
||||
VALUES: 'VALUES';
|
||||
CREATE: 'CREATE';
|
||||
TABLE: 'TABLE';
|
||||
@ -270,6 +271,7 @@ SYSTEM_TIME: 'SYSTEM_TIME';
|
||||
ENFORCED: 'ENFORCED';
|
||||
METADATA: 'METADATA';
|
||||
VIRTUAL: 'VIRTUAL';
|
||||
ZONE: 'ZONE';
|
||||
|
||||
// DATA TYPE Keywords
|
||||
|
||||
|
@ -138,15 +138,16 @@ columnName
|
||||
;
|
||||
|
||||
columnNameList
|
||||
: columnName (',' columnName)*
|
||||
: LR_BRACKET columnName (',' columnName)* RR_BRACKET
|
||||
;
|
||||
|
||||
columnType
|
||||
: typeName=(DATE | BOOLEAN | NULL)
|
||||
| typeName=(CHAR | VARCHAR | STRING | BINARY | VARBINARY | BYTES
|
||||
| TINYINT | SMALLINT | INT | INTEGER | BIGINT
|
||||
| TIME | TIMESTAMP | TIMESTAMP_LTZ | DATETIME
|
||||
| TIME | TIMESTAMP_LTZ | DATETIME
|
||||
) lengthOneDimension?
|
||||
| typeName=TIMESTAMP lengthOneDimension? ((WITHOUT | WITH) LOCAL? TIME ZONE)?
|
||||
| typeName=(DECIMAL | DEC | NUMERIC | FLOAT | DOUBLE) lengthTwoOptionalDimension?
|
||||
| type=(ARRAY | MULTISET) lengthOneTypeDimension?
|
||||
| type=MAP mapTypeDimension?
|
||||
@ -179,7 +180,7 @@ rowTypeDimension
|
||||
;
|
||||
|
||||
columnConstraint
|
||||
:(CONSTRAINT constraintName)? PRIMARY KEY (NOT ENFORCED)?
|
||||
:(CONSTRAINT constraintName)? PRIMARY KEY NOT ENFORCED
|
||||
;
|
||||
|
||||
commentSpec
|
||||
@ -208,7 +209,7 @@ watermarkDefinition
|
||||
;
|
||||
|
||||
tableConstraint
|
||||
: (CONSTRAINT constraintName)? PRIMARY KEY '(' columnNameList ')' (NOT ENFORCED)?
|
||||
: (CONSTRAINT constraintName)? PRIMARY KEY columnNameList NOT ENFORCED
|
||||
;
|
||||
|
||||
constraintName
|
||||
@ -247,8 +248,8 @@ sourceTable
|
||||
;
|
||||
|
||||
likeOption
|
||||
: (INCLUDING | EXCLUDING) (ALL | CONSTRAINTS | PARTITIONS)
|
||||
| (INCLUDING | EXCLUDING | OVERWRITING) (GENERATED | OPTIONS | WATERMARKS)
|
||||
: ((INCLUDING | EXCLUDING) (ALL | CONSTRAINTS | PARTITIONS))
|
||||
| ((INCLUDING | EXCLUDING | OVERWRITING) (GENERATED | OPTIONS | WATERMARKS))
|
||||
;
|
||||
|
||||
createCatalog
|
||||
@ -334,7 +335,7 @@ insertStatement
|
||||
insertSimpleStatement
|
||||
: INSERT (INTO | OVERWRITE) uid
|
||||
(
|
||||
insertPartitionDefinition? insertColumnListDefinition? queryStatement
|
||||
insertPartitionDefinition? columnNameList? queryStatement
|
||||
| valuesDefinition
|
||||
)
|
||||
;
|
||||
@ -343,10 +344,6 @@ insertPartitionDefinition
|
||||
: PARTITION tablePropertyList
|
||||
;
|
||||
|
||||
insertColumnListDefinition
|
||||
: LR_BRACKET columnNameList RR_BRACKET
|
||||
;
|
||||
|
||||
valuesDefinition
|
||||
: VALUES valuesRowDefinition (COMMA valuesRowDefinition)*
|
||||
;
|
||||
|
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 it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
|
||||
// Generated from /Users/mortalYoung/Projects/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
|
||||
|
||||
import {ParseTreeListener} from "antlr4";
|
||||
|
||||
@ -75,7 +75,6 @@ import { DropFunctionContext } from "./FlinkSqlParser";
|
||||
import { InsertStatementContext } from "./FlinkSqlParser";
|
||||
import { InsertSimpleStatementContext } from "./FlinkSqlParser";
|
||||
import { InsertPartitionDefinitionContext } from "./FlinkSqlParser";
|
||||
import { InsertColumnListDefinitionContext } from "./FlinkSqlParser";
|
||||
import { ValuesDefinitionContext } from "./FlinkSqlParser";
|
||||
import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
|
||||
import { InsertMulStatementCompatibilityContext } from "./FlinkSqlParser";
|
||||
@ -913,16 +912,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
exitInsertPartitionDefinition?: (ctx: InsertPartitionDefinitionContext) => void;
|
||||
/**
|
||||
* Enter a parse tree produced by `FlinkSqlParser.insertColumnListDefinition`.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
enterInsertColumnListDefinition?: (ctx: InsertColumnListDefinitionContext) => void;
|
||||
/**
|
||||
* Exit a parse tree produced by `FlinkSqlParser.insertColumnListDefinition`.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
exitInsertColumnListDefinition?: (ctx: InsertColumnListDefinitionContext) => void;
|
||||
/**
|
||||
* Enter a parse tree produced by `FlinkSqlParser.valuesDefinition`.
|
||||
* @param ctx the parse tree
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
|
||||
// Generated from /Users/mortalYoung/Projects/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
|
||||
|
||||
import {ParseTreeVisitor} from 'antlr4';
|
||||
|
||||
@ -75,7 +75,6 @@ import { DropFunctionContext } from "./FlinkSqlParser";
|
||||
import { InsertStatementContext } from "./FlinkSqlParser";
|
||||
import { InsertSimpleStatementContext } from "./FlinkSqlParser";
|
||||
import { InsertPartitionDefinitionContext } from "./FlinkSqlParser";
|
||||
import { InsertColumnListDefinitionContext } from "./FlinkSqlParser";
|
||||
import { ValuesDefinitionContext } from "./FlinkSqlParser";
|
||||
import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
|
||||
import { InsertMulStatementCompatibilityContext } from "./FlinkSqlParser";
|
||||
@ -626,12 +625,6 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
|
||||
* @return the visitor result
|
||||
*/
|
||||
visitInsertPartitionDefinition?: (ctx: InsertPartitionDefinitionContext) => Result;
|
||||
/**
|
||||
* Visit a parse tree produced by `FlinkSqlParser.insertColumnListDefinition`.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
visitInsertColumnListDefinition?: (ctx: InsertColumnListDefinitionContext) => Result;
|
||||
/**
|
||||
* Visit a parse tree produced by `FlinkSqlParser.valuesDefinition`.
|
||||
* @param ctx the parse tree
|
||||
|
Reference in New Issue
Block a user