lsyldliu commented on code in PR #19193:
URL: https://github.com/apache/flink/pull/19193#discussion_r906756236
##########
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java:
##########
@@ -313,6 +313,175 @@ void testAlterTable() {
sql(sql3).ok(expected3);
}
+ @Test
+ void testAlterTableAdd() {
+ // add single column
+ sql("alter table t1 add new_column string comment 'new_column docs'")
+ .ok("ALTER TABLE `T1` ADD `NEW_COLUMN` STRING COMMENT
'new_column docs'");
+ sql("alter table t1 add new_column string comment 'new_column docs'
first")
+ .ok("ALTER TABLE `T1` ADD `NEW_COLUMN` STRING COMMENT
'new_column docs' FIRST");
+ sql("alter table t1 add new_column string comment 'new_column docs'
after id")
+ .ok(
+ "ALTER TABLE `T1` ADD `NEW_COLUMN` STRING COMMENT
'new_column docs' AFTER `ID`");
+ // add compute column
+ sql("alter table t1 add col_int as col_a - col_b after col_b")
+ .ok("ALTER TABLE `T1` ADD `COL_INT` AS (`COL_A` - `COL_B`)
AFTER `COL_B`");
+ // add metadata column
+ sql("alter table t1 add col_int int metadata from 'mk1' virtual
comment 'comment_metadata' after col_b")
+ .ok(
+ "ALTER TABLE `T1` ADD `COL_INT` INTEGER METADATA FROM
'mk1' VIRTUAL "
+ + "COMMENT 'comment_metadata' AFTER `COL_B`");
+
+ // add watermark
+ sql("alter table t1 add watermark for ts as ts - interval '1' second")
+ .ok("ALTER TABLE `T1` ADD WATERMARK FOR `TS` AS (`TS` -
INTERVAL '1' SECOND)");
+ sql("alter table default_database.t1 add watermark for ts as ts -
interval '1' second")
+ .ok(
+ "ALTER TABLE `DEFAULT_DATABASE`.`T1` ADD WATERMARK FOR
`TS` AS (`TS` - INTERVAL '1' SECOND)");
+ sql("alter table default_catalog.default_database.t1 add watermark for
ts as ts - interval '1' second")
+ .ok(
+ "ALTER TABLE `DEFAULT_CATALOG`.`DEFAULT_DATABASE`.`T1`
"
+ + "ADD WATERMARK FOR `TS` AS (`TS` - INTERVAL
'1' SECOND)");
+
Review Comment:
This is covered by `testAlterTable`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]