feat: update alter and drop statements (#94)

* feat: add UNIQUE keyword

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* feat: support ifExist, addConstraint, dropConstraint and addUnique of alter table statement

* tests: add tests of alter statements

* docs: add comments for sql syntax

* build: optimize promote of build/antlr4

* ci: add max_old_space_size

* ci: add max_old_space_size

* ci: update tests script
This commit is contained in:
Ziv 2023-05-17 10:00:35 +08:00 committed by GitHub
parent 10645087de
commit fbee70cde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 4341 additions and 3802 deletions

View File

@ -62,20 +62,16 @@ jobs:
path: node_modules path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }} key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
- name: Test utils - name: Run Units Test
run: npx jest test/utils run: |
- name: Test FLinkSQL export NODE_OPTIONS="--max_old_space_size=4096"
run: npx jest test/parser/flinksql npx jest test/utils
- name: Test SparkSQL npx jest test/parser/flinksql
run: npx jest test/parser/spark npx jest test/parser/spark
- name: Test GenericSQL npx jest test/parser/generic
run: npx jest test/parser/generic npx jest test/parser/hive
- name: Test HiveSQL npx jest test/parser/pgsql
run: npx jest test/parser/hive npx jest test/parser/plsql
- name: Test PGSQL
run: npx jest test/parser/pgsql
- name: Test PLSQL
run: npx jest test/parser/plsql
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [setup] needs: [setup]

View File

@ -43,7 +43,7 @@ if (argv.all) { // build all: yarn antlr4 --all
if (supportedLanguage) { if (supportedLanguage) {
compile(argv.lang); compile(argv.lang);
} else { } else {
console.error('Unsupported language: ' + argv.lang); console.error('Invalid language: ' + argv.lang + ', supported languages:\n' + entry.join(', '));
} }
} else { } else {
console.error('Please to specify the language, just like: yarn antlr4 --lang flinksql'); console.error('Please to specify the language, just like: yarn antlr4 --lang flinksql');

View File

@ -265,6 +265,7 @@ CATALOGS: 'CATALOGS';
VIEWS: 'VIEWS'; VIEWS: 'VIEWS';
JARS: 'JARS'; JARS: 'JARS';
PRIMARY: 'PRIMARY'; PRIMARY: 'PRIMARY';
UNIQUE: 'UNIQUE';
KEY: 'KEY'; KEY: 'KEY';
PERIOD: 'PERIOD'; PERIOD: 'PERIOD';
SYSTEM_TIME: 'SYSTEM_TIME'; SYSTEM_TIME: 'SYSTEM_TIME';

View File

@ -277,19 +277,37 @@ jarFileName
; ;
// Alter statements // Alter statements
// Just for simple alter table statements,
// it only includes rename, set key, add constraint, drop constraint, add unique
alterTable alterTable
: ALTER TABLE uid (renameDefinition | setKeyValueDefinition) : ALTER TABLE ifExists? uid (renameDefinition | setKeyValueDefinition | addConstraint | dropConstraint | addUnique)
; ;
renameDefinition renameDefinition
: RENAME TO uid : RENAME uid? TO uid
; ;
setKeyValueDefinition setKeyValueDefinition
: SET tablePropertyList : SET tablePropertyList
; ;
addConstraint
: ADD CONSTRAINT constraintName PRIMARY KEY columnNameList notForced?
;
dropConstraint
: DROP CONSTRAINT constraintName
;
addUnique
: ADD UNIQUE columnNameList
;
notForced
: NOT ENFORCED
;
alertView alertView
: ALTER VIEW uid (renameDefinition | AS queryStatement) : ALTER VIEW uid (renameDefinition | AS queryStatement)
; ;

File diff suppressed because one or more lines are too long

View File

@ -254,78 +254,79 @@ CATALOGS=253
VIEWS=254 VIEWS=254
JARS=255 JARS=255
PRIMARY=256 PRIMARY=256
KEY=257 UNIQUE=257
PERIOD=258 KEY=258
SYSTEM_TIME=259 PERIOD=259
ENFORCED=260 SYSTEM_TIME=260
METADATA=261 ENFORCED=261
VIRTUAL=262 METADATA=262
ZONE=263 VIRTUAL=263
STRING=264 ZONE=264
ARRAY=265 STRING=265
MAP=266 ARRAY=266
CHAR=267 MAP=267
VARCHAR=268 CHAR=268
BINARY=269 VARCHAR=269
VARBINARY=270 BINARY=270
BYTES=271 VARBINARY=271
DECIMAL=272 BYTES=272
DEC=273 DECIMAL=273
NUMERIC=274 DEC=274
TINYINT=275 NUMERIC=275
SMALLINT=276 TINYINT=276
INT=277 SMALLINT=277
INTEGER=278 INT=278
BIGINT=279 INTEGER=279
FLOAT=280 BIGINT=280
DOUBLE=281 FLOAT=281
DATE=282 DOUBLE=282
TIME=283 DATE=283
TIMESTAMP=284 TIME=284
TIMESTAMP_LTZ=285 TIMESTAMP=285
MULTISET=286 TIMESTAMP_LTZ=286
BOOLEAN=287 MULTISET=287
RAW=288 BOOLEAN=288
ROW=289 RAW=289
NULL=290 ROW=290
DATETIME=291 NULL=291
EQUAL_SYMBOL=292 DATETIME=292
GREATER_SYMBOL=293 EQUAL_SYMBOL=293
LESS_SYMBOL=294 GREATER_SYMBOL=294
EXCLAMATION_SYMBOL=295 LESS_SYMBOL=295
BIT_NOT_OP=296 EXCLAMATION_SYMBOL=296
BIT_OR_OP=297 BIT_NOT_OP=297
BIT_AND_OP=298 BIT_OR_OP=298
BIT_XOR_OP=299 BIT_AND_OP=299
DOT=300 BIT_XOR_OP=300
LS_BRACKET=301 DOT=301
RS_BRACKET=302 LS_BRACKET=302
LR_BRACKET=303 RS_BRACKET=303
RR_BRACKET=304 LR_BRACKET=304
COMMA=305 RR_BRACKET=305
SEMICOLON=306 COMMA=306
AT_SIGN=307 SEMICOLON=307
SINGLE_QUOTE_SYMB=308 AT_SIGN=308
DOUBLE_QUOTE_SYMB=309 SINGLE_QUOTE_SYMB=309
REVERSE_QUOTE_SYMB=310 DOUBLE_QUOTE_SYMB=310
COLON_SYMB=311 REVERSE_QUOTE_SYMB=311
ASTERISK_SIGN=312 COLON_SYMB=312
UNDERLINE_SIGN=313 ASTERISK_SIGN=313
HYPNEN_SIGN=314 UNDERLINE_SIGN=314
ADD_SIGN=315 HYPNEN_SIGN=315
PENCENT_SIGN=316 ADD_SIGN=316
DOUBLE_VERTICAL_SIGN=317 PENCENT_SIGN=317
DOUBLE_HYPNEN_SIGN=318 DOUBLE_VERTICAL_SIGN=318
SLASH_SIGN=319 DOUBLE_HYPNEN_SIGN=319
DOT_ID=320 SLASH_SIGN=320
PLUS_DOT_ID=321 DOT_ID=321
STRING_LITERAL=322 PLUS_DOT_ID=322
DIG_LITERAL=323 STRING_LITERAL=323
REAL_LITERAL=324 DIG_LITERAL=324
BIT_STRING=325 REAL_LITERAL=325
ID_LITERAL=326 BIT_STRING=326
PLUS_ID_LITERAL=327 ID_LITERAL=327
FILE_PATH=328 PLUS_ID_LITERAL=328
FILE_PATH=329
'SELECT'=4 'SELECT'=4
'FROM'=5 'FROM'=5
'ADD'=6 'ADD'=6
@ -579,66 +580,67 @@ FILE_PATH=328
'VIEWS'=254 'VIEWS'=254
'JARS'=255 'JARS'=255
'PRIMARY'=256 'PRIMARY'=256
'KEY'=257 'UNIQUE'=257
'PERIOD'=258 'KEY'=258
'SYSTEM_TIME'=259 'PERIOD'=259
'ENFORCED'=260 'SYSTEM_TIME'=260
'METADATA'=261 'ENFORCED'=261
'VIRTUAL'=262 'METADATA'=262
'ZONE'=263 'VIRTUAL'=263
'STRING'=264 'ZONE'=264
'ARRAY'=265 'STRING'=265
'MAP'=266 'ARRAY'=266
'CHAR'=267 'MAP'=267
'VARCHAR'=268 'CHAR'=268
'BINARY'=269 'VARCHAR'=269
'VARBINARY'=270 'BINARY'=270
'BYTES'=271 'VARBINARY'=271
'DECIMAL'=272 'BYTES'=272
'DEC'=273 'DECIMAL'=273
'NUMERIC'=274 'DEC'=274
'TINYINT'=275 'NUMERIC'=275
'SMALLINT'=276 'TINYINT'=276
'INT'=277 'SMALLINT'=277
'INTEGER'=278 'INT'=278
'BIGINT'=279 'INTEGER'=279
'FLOAT'=280 'BIGINT'=280
'DOUBLE'=281 'FLOAT'=281
'DATE'=282 'DOUBLE'=282
'TIME'=283 'DATE'=283
'TIMESTAMP'=284 'TIME'=284
'TIMESTAMP_LTZ'=285 'TIMESTAMP'=285
'MULTISET'=286 'TIMESTAMP_LTZ'=286
'BOOLEAN'=287 'MULTISET'=287
'RAW'=288 'BOOLEAN'=288
'ROW'=289 'RAW'=289
'NULL'=290 'ROW'=290
'DATETIME'=291 'NULL'=291
'='=292 'DATETIME'=292
'>'=293 '='=293
'<'=294 '>'=294
'!'=295 '<'=295
'~'=296 '!'=296
'|'=297 '~'=297
'&'=298 '|'=298
'^'=299 '&'=299
'.'=300 '^'=300
'['=301 '.'=301
']'=302 '['=302
'('=303 ']'=303
')'=304 '('=304
','=305 ')'=305
';'=306 ','=306
'@'=307 ';'=307
'\''=308 '@'=308
'"'=309 '\''=309
'`'=310 '"'=310
':'=311 '`'=311
'*'=312 ':'=312
'_'=313 '*'=313
'-'=314 '_'=314
'+'=315 '-'=315
'%'=316 '+'=316
'||'=317 '%'=317
'--'=318 '||'=318
'/'=319 '--'=319
'/'=320

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -254,78 +254,79 @@ CATALOGS=253
VIEWS=254 VIEWS=254
JARS=255 JARS=255
PRIMARY=256 PRIMARY=256
KEY=257 UNIQUE=257
PERIOD=258 KEY=258
SYSTEM_TIME=259 PERIOD=259
ENFORCED=260 SYSTEM_TIME=260
METADATA=261 ENFORCED=261
VIRTUAL=262 METADATA=262
ZONE=263 VIRTUAL=263
STRING=264 ZONE=264
ARRAY=265 STRING=265
MAP=266 ARRAY=266
CHAR=267 MAP=267
VARCHAR=268 CHAR=268
BINARY=269 VARCHAR=269
VARBINARY=270 BINARY=270
BYTES=271 VARBINARY=271
DECIMAL=272 BYTES=272
DEC=273 DECIMAL=273
NUMERIC=274 DEC=274
TINYINT=275 NUMERIC=275
SMALLINT=276 TINYINT=276
INT=277 SMALLINT=277
INTEGER=278 INT=278
BIGINT=279 INTEGER=279
FLOAT=280 BIGINT=280
DOUBLE=281 FLOAT=281
DATE=282 DOUBLE=282
TIME=283 DATE=283
TIMESTAMP=284 TIME=284
TIMESTAMP_LTZ=285 TIMESTAMP=285
MULTISET=286 TIMESTAMP_LTZ=286
BOOLEAN=287 MULTISET=287
RAW=288 BOOLEAN=288
ROW=289 RAW=289
NULL=290 ROW=290
DATETIME=291 NULL=291
EQUAL_SYMBOL=292 DATETIME=292
GREATER_SYMBOL=293 EQUAL_SYMBOL=293
LESS_SYMBOL=294 GREATER_SYMBOL=294
EXCLAMATION_SYMBOL=295 LESS_SYMBOL=295
BIT_NOT_OP=296 EXCLAMATION_SYMBOL=296
BIT_OR_OP=297 BIT_NOT_OP=297
BIT_AND_OP=298 BIT_OR_OP=298
BIT_XOR_OP=299 BIT_AND_OP=299
DOT=300 BIT_XOR_OP=300
LS_BRACKET=301 DOT=301
RS_BRACKET=302 LS_BRACKET=302
LR_BRACKET=303 RS_BRACKET=303
RR_BRACKET=304 LR_BRACKET=304
COMMA=305 RR_BRACKET=305
SEMICOLON=306 COMMA=306
AT_SIGN=307 SEMICOLON=307
SINGLE_QUOTE_SYMB=308 AT_SIGN=308
DOUBLE_QUOTE_SYMB=309 SINGLE_QUOTE_SYMB=309
REVERSE_QUOTE_SYMB=310 DOUBLE_QUOTE_SYMB=310
COLON_SYMB=311 REVERSE_QUOTE_SYMB=311
ASTERISK_SIGN=312 COLON_SYMB=312
UNDERLINE_SIGN=313 ASTERISK_SIGN=313
HYPNEN_SIGN=314 UNDERLINE_SIGN=314
ADD_SIGN=315 HYPNEN_SIGN=315
PENCENT_SIGN=316 ADD_SIGN=316
DOUBLE_VERTICAL_SIGN=317 PENCENT_SIGN=317
DOUBLE_HYPNEN_SIGN=318 DOUBLE_VERTICAL_SIGN=318
SLASH_SIGN=319 DOUBLE_HYPNEN_SIGN=319
DOT_ID=320 SLASH_SIGN=320
PLUS_DOT_ID=321 DOT_ID=321
STRING_LITERAL=322 PLUS_DOT_ID=322
DIG_LITERAL=323 STRING_LITERAL=323
REAL_LITERAL=324 DIG_LITERAL=324
BIT_STRING=325 REAL_LITERAL=325
ID_LITERAL=326 BIT_STRING=326
PLUS_ID_LITERAL=327 ID_LITERAL=327
FILE_PATH=328 PLUS_ID_LITERAL=328
FILE_PATH=329
'SELECT'=4 'SELECT'=4
'FROM'=5 'FROM'=5
'ADD'=6 'ADD'=6
@ -579,66 +580,67 @@ FILE_PATH=328
'VIEWS'=254 'VIEWS'=254
'JARS'=255 'JARS'=255
'PRIMARY'=256 'PRIMARY'=256
'KEY'=257 'UNIQUE'=257
'PERIOD'=258 'KEY'=258
'SYSTEM_TIME'=259 'PERIOD'=259
'ENFORCED'=260 'SYSTEM_TIME'=260
'METADATA'=261 'ENFORCED'=261
'VIRTUAL'=262 'METADATA'=262
'ZONE'=263 'VIRTUAL'=263
'STRING'=264 'ZONE'=264
'ARRAY'=265 'STRING'=265
'MAP'=266 'ARRAY'=266
'CHAR'=267 'MAP'=267
'VARCHAR'=268 'CHAR'=268
'BINARY'=269 'VARCHAR'=269
'VARBINARY'=270 'BINARY'=270
'BYTES'=271 'VARBINARY'=271
'DECIMAL'=272 'BYTES'=272
'DEC'=273 'DECIMAL'=273
'NUMERIC'=274 'DEC'=274
'TINYINT'=275 'NUMERIC'=275
'SMALLINT'=276 'TINYINT'=276
'INT'=277 'SMALLINT'=277
'INTEGER'=278 'INT'=278
'BIGINT'=279 'INTEGER'=279
'FLOAT'=280 'BIGINT'=280
'DOUBLE'=281 'FLOAT'=281
'DATE'=282 'DOUBLE'=282
'TIME'=283 'DATE'=283
'TIMESTAMP'=284 'TIME'=284
'TIMESTAMP_LTZ'=285 'TIMESTAMP'=285
'MULTISET'=286 'TIMESTAMP_LTZ'=286
'BOOLEAN'=287 'MULTISET'=287
'RAW'=288 'BOOLEAN'=288
'ROW'=289 'RAW'=289
'NULL'=290 'ROW'=290
'DATETIME'=291 'NULL'=291
'='=292 'DATETIME'=292
'>'=293 '='=293
'<'=294 '>'=294
'!'=295 '<'=295
'~'=296 '!'=296
'|'=297 '~'=297
'&'=298 '|'=298
'^'=299 '&'=299
'.'=300 '^'=300
'['=301 '.'=301
']'=302 '['=302
'('=303 ']'=303
')'=304 '('=304
','=305 ')'=305
';'=306 ','=306
'@'=307 ';'=307
'\''=308 '@'=308
'"'=309 '\''=309
'`'=310 '"'=310
':'=311 '`'=311
'*'=312 ':'=312
'_'=313 '*'=313
'-'=314 '_'=314
'+'=315 '-'=315
'%'=316 '+'=316
'||'=317 '%'=317
'--'=318 '||'=318
'/'=319 '--'=319
'/'=320

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/zhenglin/Documents/parser/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0 // Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeListener} from "antlr4"; import {ParseTreeListener} from "antlr4";
@ -64,6 +64,10 @@ import { JarFileNameContext } from "./FlinkSqlParser";
import { AlterTableContext } from "./FlinkSqlParser"; import { AlterTableContext } from "./FlinkSqlParser";
import { RenameDefinitionContext } from "./FlinkSqlParser"; import { RenameDefinitionContext } from "./FlinkSqlParser";
import { SetKeyValueDefinitionContext } from "./FlinkSqlParser"; import { SetKeyValueDefinitionContext } from "./FlinkSqlParser";
import { AddConstraintContext } from "./FlinkSqlParser";
import { DropConstraintContext } from "./FlinkSqlParser";
import { AddUniqueContext } from "./FlinkSqlParser";
import { NotForcedContext } from "./FlinkSqlParser";
import { AlertViewContext } from "./FlinkSqlParser"; import { AlertViewContext } from "./FlinkSqlParser";
import { AlterDatabaseContext } from "./FlinkSqlParser"; import { AlterDatabaseContext } from "./FlinkSqlParser";
import { AlterFunctionContext } from "./FlinkSqlParser"; import { AlterFunctionContext } from "./FlinkSqlParser";
@ -801,6 +805,46 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitSetKeyValueDefinition?: (ctx: SetKeyValueDefinitionContext) => void; exitSetKeyValueDefinition?: (ctx: SetKeyValueDefinitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.addConstraint`.
* @param ctx the parse tree
*/
enterAddConstraint?: (ctx: AddConstraintContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.addConstraint`.
* @param ctx the parse tree
*/
exitAddConstraint?: (ctx: AddConstraintContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.dropConstraint`.
* @param ctx the parse tree
*/
enterDropConstraint?: (ctx: DropConstraintContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.dropConstraint`.
* @param ctx the parse tree
*/
exitDropConstraint?: (ctx: DropConstraintContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.addUnique`.
* @param ctx the parse tree
*/
enterAddUnique?: (ctx: AddUniqueContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.addUnique`.
* @param ctx the parse tree
*/
exitAddUnique?: (ctx: AddUniqueContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.notForced`.
* @param ctx the parse tree
*/
enterNotForced?: (ctx: NotForcedContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.notForced`.
* @param ctx the parse tree
*/
exitNotForced?: (ctx: NotForcedContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.alertView`. * Enter a parse tree produced by `FlinkSqlParser.alertView`.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from /Users/zhenglin/Documents/parser/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0 // Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeVisitor} from 'antlr4'; import {ParseTreeVisitor} from 'antlr4';
@ -64,6 +64,10 @@ import { JarFileNameContext } from "./FlinkSqlParser";
import { AlterTableContext } from "./FlinkSqlParser"; import { AlterTableContext } from "./FlinkSqlParser";
import { RenameDefinitionContext } from "./FlinkSqlParser"; import { RenameDefinitionContext } from "./FlinkSqlParser";
import { SetKeyValueDefinitionContext } from "./FlinkSqlParser"; import { SetKeyValueDefinitionContext } from "./FlinkSqlParser";
import { AddConstraintContext } from "./FlinkSqlParser";
import { DropConstraintContext } from "./FlinkSqlParser";
import { AddUniqueContext } from "./FlinkSqlParser";
import { NotForcedContext } from "./FlinkSqlParser";
import { AlertViewContext } from "./FlinkSqlParser"; import { AlertViewContext } from "./FlinkSqlParser";
import { AlterDatabaseContext } from "./FlinkSqlParser"; import { AlterDatabaseContext } from "./FlinkSqlParser";
import { AlterFunctionContext } from "./FlinkSqlParser"; import { AlterFunctionContext } from "./FlinkSqlParser";
@ -558,6 +562,30 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitSetKeyValueDefinition?: (ctx: SetKeyValueDefinitionContext) => Result; visitSetKeyValueDefinition?: (ctx: SetKeyValueDefinitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.addConstraint`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAddConstraint?: (ctx: AddConstraintContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.dropConstraint`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDropConstraint?: (ctx: DropConstraintContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.addUnique`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAddUnique?: (ctx: AddUniqueContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.notForced`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNotForced?: (ctx: NotForcedContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.alertView`. * Visit a parse tree produced by `FlinkSqlParser.alertView`.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -1 +1,3 @@
ALTER DATABASE tempDB SET ("key1"="value1"); ALTER DATABASE tempDB SET ("key1"="value1");
alter database db1 set ('key1' = 'value1','key2.a' = 'value2.a');

View File

@ -1,7 +1,15 @@
ALTER FUNCTION tempFunction AS 'SimpleUdf'; ALTER FUNCTION tempFunction AS 'SimpleUdf';
ALTER TEMPORARY FUNCTION IF EXISTS tempFunction AS 'SimpleUdf'; alter temporary function function1 as 'org.apache.flink.function.function1';
alter temporary function function1 as 'org.apache.flink.function.function1' language scala;
alter temporary system function function1 as 'org.apache.flink.function.function1';
alter temporary system function function1 as 'org.apache.flink.function.function1' language java;
ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf'; ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
ALTER TEMPORARY FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
ALTER FUNCTION myudf AS 'com.example.MyUdf' LANGUAGE PYTHON; ALTER FUNCTION myudf AS 'com.example.MyUdf' LANGUAGE PYTHON;

View File

@ -1,7 +1,65 @@
ALTER TABLE -- Refer: https://github.com/apache/flink/blob/master/flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java#L2016
Orders RENAME TO NewOrders; -- Just for simple alter table statements, it not include alter table columns statements
alter table
t1 rename to t2;
alter table
if exists t1 rename to t2;
alter table
c1.d1.t1 rename to t2;
alter table
if exists c1.d1.t1 rename to t2;
alter table
t1 rename a to b;
alter table
if exists t1 rename a to b;
alter table
if exists t1 rename a.x to a.y;
alter table
t1
set
('key1' = 'value1');
alter table
if exists t1
set
('key1' = 'value1');
alter table
t1
add
constraint ct1 primary key(a, b);
alter table
t1
add
constraint ct1 primary key(a, b) not enforced;
alter table
if exists t1
add
constraint ct1 primary key(a, b) not enforced;
alter table
t1
add
unique(a, b);
alter table
if exists t1
add
unique(a, b);
alter table
t1 drop constraint ct1;
alter table
if exists t1 drop constraint ct1;
ALTER TABLE
sample_table
SET
('key1' = 'value2');