|
31 | 31 | import org.apache.flink.cdc.common.schema.Column;
|
32 | 32 | import org.apache.flink.cdc.common.schema.Schema;
|
33 | 33 | import org.apache.flink.cdc.common.source.FlinkSourceProvider;
|
| 34 | +import org.apache.flink.cdc.common.types.BinaryType; |
| 35 | +import org.apache.flink.cdc.common.types.CharType; |
34 | 36 | import org.apache.flink.cdc.common.types.DataType;
|
35 | 37 | import org.apache.flink.cdc.common.types.DataTypes;
|
36 | 38 | import org.apache.flink.cdc.common.types.RowType;
|
@@ -301,6 +303,48 @@ public void testParseAlterStatement() throws Exception {
|
301 | 303 | Collections.singletonList(
|
302 | 304 | new AddColumnEvent.ColumnWithPosition(
|
303 | 305 | Column.physicalColumn("cols5", DataTypes.BOOLEAN())))));
|
| 306 | + statement.execute( |
| 307 | + String.format( |
| 308 | + "ALTER TABLE `%s`.`products` ADD COLUMN `cols6` BINARY(0) NULL;", |
| 309 | + inventoryDatabase.getDatabaseName())); |
| 310 | + expected.add( |
| 311 | + new AddColumnEvent( |
| 312 | + tableId, |
| 313 | + Collections.singletonList( |
| 314 | + new AddColumnEvent.ColumnWithPosition( |
| 315 | + Column.physicalColumn( |
| 316 | + "cols6", BinaryType.ofEmptyLiteral()))))); |
| 317 | + statement.execute( |
| 318 | + String.format( |
| 319 | + "ALTER TABLE `%s`.`products` ADD COLUMN `cols7` BINARY NULL;", |
| 320 | + inventoryDatabase.getDatabaseName())); |
| 321 | + expected.add( |
| 322 | + new AddColumnEvent( |
| 323 | + tableId, |
| 324 | + Collections.singletonList( |
| 325 | + new AddColumnEvent.ColumnWithPosition( |
| 326 | + Column.physicalColumn("cols7", DataTypes.BINARY(1)))))); |
| 327 | + statement.execute( |
| 328 | + String.format( |
| 329 | + "ALTER TABLE `%s`.`products` ADD COLUMN `cols8` CHAR(0) NULL;", |
| 330 | + inventoryDatabase.getDatabaseName())); |
| 331 | + expected.add( |
| 332 | + new AddColumnEvent( |
| 333 | + tableId, |
| 334 | + Collections.singletonList( |
| 335 | + new AddColumnEvent.ColumnWithPosition( |
| 336 | + Column.physicalColumn( |
| 337 | + "cols8", CharType.ofEmptyLiteral()))))); |
| 338 | + statement.execute( |
| 339 | + String.format( |
| 340 | + "ALTER TABLE `%s`.`products` ADD COLUMN `cols9` CHAR NULL;", |
| 341 | + inventoryDatabase.getDatabaseName())); |
| 342 | + expected.add( |
| 343 | + new AddColumnEvent( |
| 344 | + tableId, |
| 345 | + Collections.singletonList( |
| 346 | + new AddColumnEvent.ColumnWithPosition( |
| 347 | + Column.physicalColumn("cols9", DataTypes.CHAR(1)))))); |
304 | 348 | }
|
305 | 349 | List<Event> actual = fetchResults(events, expected.size());
|
306 | 350 | assertThat(actual).isEqualTo(expected);
|
|
0 commit comments