Skip to content

Commit 5912ccb

Browse files
committed
support alter table: drop, rename, set, reset
1 parent 593015f commit 5912ccb

File tree

4 files changed

+6310
-4602
lines changed

4 files changed

+6310
-4602
lines changed

docs/performance/psss/v1.18.fql

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,63 @@ REPLACE TABLE my_rtas_table
55
WITH (
66
'connector' = 'kafka'
77
)
8-
AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
8+
AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
9+
10+
-- add a new column
11+
ALTER TABLE MyTable ADD category_id STRING COMMENT 'identifier of the category';
12+
13+
-- add columns, constraint, and watermark
14+
-- ALTER TABLE MyTable ADD (
15+
-- log_ts STRING COMMENT 'log timestamp string' FIRST,
16+
-- ts AS TO_TIMESTAMP(log_ts) AFTER log_ts,
17+
-- PRIMARY KEY (id) NOT ENFORCED,
18+
-- WATERMARK FOR ts AS ts - INTERVAL '3' SECOND
19+
-- );
20+
21+
-- add a new partition
22+
ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1');
23+
24+
-- add two new partitions
25+
ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1') PARTITION (p1=1,p2='b') with ('k2'='v2');
26+
27+
-- modify a column type, comment and position
28+
ALTER TABLE MyTable MODIFY measurement double COMMENT 'unit is bytes per second' AFTER `id`;
29+
30+
-- modify definition of column log_ts and ts, primary key, watermark. They must exist in table schema
31+
32+
-- ALTER TABLE MyTable MODIFY (
33+
-- log_ts STRING COMMENT 'log timestamp string' AFTER `id`, -- reorder columns
34+
-- ts AS TO_TIMESTAMP(log_ts) AFTER log_ts,
35+
-- PRIMARY KEY (id) NOT ENFORCED,
36+
-- WATERMARK FOR ts AS ts -- modify watermark strategy
37+
-- );
38+
39+
-- drop a column
40+
ALTER TABLE MyTable DROP measurement;
41+
42+
-- drop columns
43+
ALTER TABLE MyTable DROP (col1, col2, col3);
44+
45+
-- drop primary key
46+
ALTER TABLE MyTable DROP PRIMARY KEY;
47+
48+
-- drop a partition
49+
ALTER TABLE MyTable DROP PARTITION (`id` = 1);
50+
51+
-- drop two partitions
52+
ALTER TABLE MyTable DROP PARTITION (`id` = 1), PARTITION (`id` = 2);
53+
54+
-- drop a watermark
55+
ALTER TABLE MyTable DROP WATERMARK;
56+
57+
-- rename column
58+
ALTER TABLE MyTable RENAME request_body TO payload;
59+
60+
-- rename table
61+
ALTER TABLE MyTable RENAME TO MyTable2;
62+
63+
-- set 'rows-per-second'
64+
ALTER TABLE DataGenSource SET ('rows-per-second' = '10');
65+
66+
-- reset 'rows-per-second' to the default value
67+
ALTER TABLE DataGenSource RESET ('rows-per-second');

src/FlinkSQLListener.ts

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ import { ArithmeticBinaryContext } from "./FlinkSQLParser";
3131
import { ComparisonContext } from "./FlinkSQLParser";
3232
import { ArithmeticBinaryAlternateContext } from "./FlinkSQLParser";
3333
import { LengthSymbolsTypeDimensionContext } from "./FlinkSQLParser";
34+
import { AlterContext } from "./FlinkSQLParser";
35+
import { AddOrModifyNewColumnContext } from "./FlinkSQLParser";
36+
import { AddOrModifyNewColumnsContext } from "./FlinkSQLParser";
37+
import { AddNewPartitionsContext } from "./FlinkSQLParser";
38+
import { DropAcolumnContext } from "./FlinkSQLParser";
39+
import { DropColumnListContext } from "./FlinkSQLParser";
40+
import { DropPrimaryKeyContext } from "./FlinkSQLParser";
41+
import { DropPartitionsContext } from "./FlinkSQLParser";
42+
import { DropWatermarkContext } from "./FlinkSQLParser";
43+
import { RenameColumnContext } from "./FlinkSQLParser";
44+
import { RenameTableContext } from "./FlinkSQLParser";
45+
import { SetPropertiyContext } from "./FlinkSQLParser";
46+
import { ResetPropertiyContext } from "./FlinkSQLParser";
3447
import { RowSymbolsTypeDimensionContext } from "./FlinkSQLParser";
3548
import { IdentityTransformContext } from "./FlinkSQLParser";
3649
import { ApplyTransformContext } from "./FlinkSQLParser";
@@ -98,6 +111,7 @@ import { CreateFunctionContext } from "./FlinkSQLParser";
98111
import { UsingClauseContext } from "./FlinkSQLParser";
99112
import { JarFileNameContext } from "./FlinkSQLParser";
100113
import { AlterTableContext } from "./FlinkSQLParser";
114+
import { ColoumPositionContext } from "./FlinkSQLParser";
101115
import { RenameDefinitionContext } from "./FlinkSQLParser";
102116
import { SetKeyValueDefinitionContext } from "./FlinkSQLParser";
103117
import { AddConstraintContext } from "./FlinkSQLParser";
@@ -605,6 +619,175 @@ export interface FlinkSQLListener extends ParseTreeListener {
605619
*/
606620
exitLengthSymbolsTypeDimension?: (ctx: LengthSymbolsTypeDimensionContext) => void;
607621

622+
/**
623+
* Enter a parse tree produced by the `alter`
624+
* labeled alternative in `FlinkSQLParser.alterTable`.
625+
* @param ctx the parse tree
626+
*/
627+
enterAlter?: (ctx: AlterContext) => void;
628+
/**
629+
* Exit a parse tree produced by the `alter`
630+
* labeled alternative in `FlinkSQLParser.alterTable`.
631+
* @param ctx the parse tree
632+
*/
633+
exitAlter?: (ctx: AlterContext) => void;
634+
635+
/**
636+
* Enter a parse tree produced by the `addOrModifyNewColumn`
637+
* labeled alternative in `FlinkSQLParser.alterTable`.
638+
* @param ctx the parse tree
639+
*/
640+
enterAddOrModifyNewColumn?: (ctx: AddOrModifyNewColumnContext) => void;
641+
/**
642+
* Exit a parse tree produced by the `addOrModifyNewColumn`
643+
* labeled alternative in `FlinkSQLParser.alterTable`.
644+
* @param ctx the parse tree
645+
*/
646+
exitAddOrModifyNewColumn?: (ctx: AddOrModifyNewColumnContext) => void;
647+
648+
/**
649+
* Enter a parse tree produced by the `addOrModifyNewColumns`
650+
* labeled alternative in `FlinkSQLParser.alterTable`.
651+
* @param ctx the parse tree
652+
*/
653+
enterAddOrModifyNewColumns?: (ctx: AddOrModifyNewColumnsContext) => void;
654+
/**
655+
* Exit a parse tree produced by the `addOrModifyNewColumns`
656+
* labeled alternative in `FlinkSQLParser.alterTable`.
657+
* @param ctx the parse tree
658+
*/
659+
exitAddOrModifyNewColumns?: (ctx: AddOrModifyNewColumnsContext) => void;
660+
661+
/**
662+
* Enter a parse tree produced by the `addNewPartitions`
663+
* labeled alternative in `FlinkSQLParser.alterTable`.
664+
* @param ctx the parse tree
665+
*/
666+
enterAddNewPartitions?: (ctx: AddNewPartitionsContext) => void;
667+
/**
668+
* Exit a parse tree produced by the `addNewPartitions`
669+
* labeled alternative in `FlinkSQLParser.alterTable`.
670+
* @param ctx the parse tree
671+
*/
672+
exitAddNewPartitions?: (ctx: AddNewPartitionsContext) => void;
673+
674+
/**
675+
* Enter a parse tree produced by the `dropAcolumn`
676+
* labeled alternative in `FlinkSQLParser.alterTable`.
677+
* @param ctx the parse tree
678+
*/
679+
enterDropAcolumn?: (ctx: DropAcolumnContext) => void;
680+
/**
681+
* Exit a parse tree produced by the `dropAcolumn`
682+
* labeled alternative in `FlinkSQLParser.alterTable`.
683+
* @param ctx the parse tree
684+
*/
685+
exitDropAcolumn?: (ctx: DropAcolumnContext) => void;
686+
687+
/**
688+
* Enter a parse tree produced by the `dropColumnList`
689+
* labeled alternative in `FlinkSQLParser.alterTable`.
690+
* @param ctx the parse tree
691+
*/
692+
enterDropColumnList?: (ctx: DropColumnListContext) => void;
693+
/**
694+
* Exit a parse tree produced by the `dropColumnList`
695+
* labeled alternative in `FlinkSQLParser.alterTable`.
696+
* @param ctx the parse tree
697+
*/
698+
exitDropColumnList?: (ctx: DropColumnListContext) => void;
699+
700+
/**
701+
* Enter a parse tree produced by the `dropPrimaryKey`
702+
* labeled alternative in `FlinkSQLParser.alterTable`.
703+
* @param ctx the parse tree
704+
*/
705+
enterDropPrimaryKey?: (ctx: DropPrimaryKeyContext) => void;
706+
/**
707+
* Exit a parse tree produced by the `dropPrimaryKey`
708+
* labeled alternative in `FlinkSQLParser.alterTable`.
709+
* @param ctx the parse tree
710+
*/
711+
exitDropPrimaryKey?: (ctx: DropPrimaryKeyContext) => void;
712+
713+
/**
714+
* Enter a parse tree produced by the `dropPartitions`
715+
* labeled alternative in `FlinkSQLParser.alterTable`.
716+
* @param ctx the parse tree
717+
*/
718+
enterDropPartitions?: (ctx: DropPartitionsContext) => void;
719+
/**
720+
* Exit a parse tree produced by the `dropPartitions`
721+
* labeled alternative in `FlinkSQLParser.alterTable`.
722+
* @param ctx the parse tree
723+
*/
724+
exitDropPartitions?: (ctx: DropPartitionsContext) => void;
725+
726+
/**
727+
* Enter a parse tree produced by the `dropWatermark`
728+
* labeled alternative in `FlinkSQLParser.alterTable`.
729+
* @param ctx the parse tree
730+
*/
731+
enterDropWatermark?: (ctx: DropWatermarkContext) => void;
732+
/**
733+
* Exit a parse tree produced by the `dropWatermark`
734+
* labeled alternative in `FlinkSQLParser.alterTable`.
735+
* @param ctx the parse tree
736+
*/
737+
exitDropWatermark?: (ctx: DropWatermarkContext) => void;
738+
739+
/**
740+
* Enter a parse tree produced by the `renameColumn`
741+
* labeled alternative in `FlinkSQLParser.alterTable`.
742+
* @param ctx the parse tree
743+
*/
744+
enterRenameColumn?: (ctx: RenameColumnContext) => void;
745+
/**
746+
* Exit a parse tree produced by the `renameColumn`
747+
* labeled alternative in `FlinkSQLParser.alterTable`.
748+
* @param ctx the parse tree
749+
*/
750+
exitRenameColumn?: (ctx: RenameColumnContext) => void;
751+
752+
/**
753+
* Enter a parse tree produced by the `renameTable`
754+
* labeled alternative in `FlinkSQLParser.alterTable`.
755+
* @param ctx the parse tree
756+
*/
757+
enterRenameTable?: (ctx: RenameTableContext) => void;
758+
/**
759+
* Exit a parse tree produced by the `renameTable`
760+
* labeled alternative in `FlinkSQLParser.alterTable`.
761+
* @param ctx the parse tree
762+
*/
763+
exitRenameTable?: (ctx: RenameTableContext) => void;
764+
765+
/**
766+
* Enter a parse tree produced by the `setPropertiy`
767+
* labeled alternative in `FlinkSQLParser.alterTable`.
768+
* @param ctx the parse tree
769+
*/
770+
enterSetPropertiy?: (ctx: SetPropertiyContext) => void;
771+
/**
772+
* Exit a parse tree produced by the `setPropertiy`
773+
* labeled alternative in `FlinkSQLParser.alterTable`.
774+
* @param ctx the parse tree
775+
*/
776+
exitSetPropertiy?: (ctx: SetPropertiyContext) => void;
777+
778+
/**
779+
* Enter a parse tree produced by the `resetPropertiy`
780+
* labeled alternative in `FlinkSQLParser.alterTable`.
781+
* @param ctx the parse tree
782+
*/
783+
enterResetPropertiy?: (ctx: ResetPropertiyContext) => void;
784+
/**
785+
* Exit a parse tree produced by the `resetPropertiy`
786+
* labeled alternative in `FlinkSQLParser.alterTable`.
787+
* @param ctx the parse tree
788+
*/
789+
exitResetPropertiy?: (ctx: ResetPropertiyContext) => void;
790+
608791
/**
609792
* Enter a parse tree produced by the `rowSymbolsTypeDimension`
610793
* labeled alternative in `FlinkSQLParser.rowTypeDimension`.
@@ -1358,6 +1541,17 @@ export interface FlinkSQLListener extends ParseTreeListener {
13581541
*/
13591542
exitAlterTable?: (ctx: AlterTableContext) => void;
13601543

1544+
/**
1545+
* Enter a parse tree produced by `FlinkSQLParser.coloumPosition`.
1546+
* @param ctx the parse tree
1547+
*/
1548+
enterColoumPosition?: (ctx: ColoumPositionContext) => void;
1549+
/**
1550+
* Exit a parse tree produced by `FlinkSQLParser.coloumPosition`.
1551+
* @param ctx the parse tree
1552+
*/
1553+
exitColoumPosition?: (ctx: ColoumPositionContext) => void;
1554+
13611555
/**
13621556
* Enter a parse tree produced by `FlinkSQLParser.renameDefinition`.
13631557
* @param ctx the parse tree

0 commit comments

Comments
 (0)