|
21 | 21 | import org.apache.flink.cdc.common.event.AddColumnEvent; |
22 | 22 | import org.apache.flink.cdc.common.event.CreateTableEvent; |
23 | 23 | import org.apache.flink.cdc.common.event.DropColumnEvent; |
24 | | -import org.apache.flink.cdc.common.event.RenameColumnEvent; |
25 | 24 | import org.apache.flink.cdc.common.event.TableId; |
26 | 25 | import org.apache.flink.cdc.common.schema.Column; |
27 | 26 | import org.apache.flink.cdc.common.schema.Schema; |
|
42 | 41 | import java.util.ArrayList; |
43 | 42 | import java.util.Arrays; |
44 | 43 | import java.util.Collections; |
45 | | -import java.util.HashMap; |
46 | 44 | import java.util.List; |
47 | | -import java.util.Map; |
48 | 45 |
|
49 | 46 | import static org.apache.flink.cdc.connectors.starrocks.sink.StarRocksDataSinkOptions.TABLE_CREATE_NUM_BUCKETS; |
50 | 47 | import static org.apache.flink.cdc.connectors.starrocks.sink.StarRocksDataSinkOptions.TABLE_SCHEMA_CHANGE_TIMEOUT; |
@@ -229,63 +226,4 @@ void testDropColumn() throws Exception { |
229 | 226 | .build(); |
230 | 227 | Assertions.assertThat(actualTable).isEqualTo(expectTable); |
231 | 228 | } |
232 | | - |
233 | | - @Test |
234 | | - void testRenameColumn() throws Exception { |
235 | | - TableId tableId = TableId.parse("test.tbl4"); |
236 | | - Schema schema = |
237 | | - Schema.newBuilder() |
238 | | - .physicalColumn("col1", new IntType()) |
239 | | - .physicalColumn("col2", new BooleanType()) |
240 | | - .physicalColumn("col3", new TimestampType()) |
241 | | - .primaryKey("col1") |
242 | | - .build(); |
243 | | - CreateTableEvent createTableEvent = new CreateTableEvent(tableId, schema); |
244 | | - metadataApplier.applySchemaChange(createTableEvent); |
245 | | - |
246 | | - Map<String, String> nameMapping = new HashMap<>(); |
247 | | - nameMapping.put("col2", "newCol2"); |
248 | | - nameMapping.put("col3", "newCol3"); |
249 | | - RenameColumnEvent renameColumnEvent = new RenameColumnEvent(tableId, nameMapping); |
250 | | - metadataApplier.applySchemaChange(renameColumnEvent); |
251 | | - |
252 | | - StarRocksTable actualTable = |
253 | | - catalog.getTable(tableId.getSchemaName(), tableId.getTableName()).orElse(null); |
254 | | - Assertions.assertThat(actualTable).isNotNull(); |
255 | | - |
256 | | - List<StarRocksColumn> columns = new ArrayList<>(); |
257 | | - columns.add( |
258 | | - new StarRocksColumn.Builder() |
259 | | - .setColumnName("col1") |
260 | | - .setOrdinalPosition(0) |
261 | | - .setDataType("int") |
262 | | - .setNullable(true) |
263 | | - .build()); |
264 | | - columns.add( |
265 | | - new StarRocksColumn.Builder() |
266 | | - .setColumnName("newCol2") |
267 | | - .setOrdinalPosition(1) |
268 | | - .setDataType("boolean") |
269 | | - .setNullable(true) |
270 | | - .build()); |
271 | | - columns.add( |
272 | | - new StarRocksColumn.Builder() |
273 | | - .setColumnName("newCol3") |
274 | | - .setOrdinalPosition(2) |
275 | | - .setDataType("datetime") |
276 | | - .setNullable(true) |
277 | | - .build()); |
278 | | - StarRocksTable expectTable = |
279 | | - new StarRocksTable.Builder() |
280 | | - .setDatabaseName(tableId.getSchemaName()) |
281 | | - .setTableName(tableId.getTableName()) |
282 | | - .setTableType(StarRocksTable.TableType.PRIMARY_KEY) |
283 | | - .setColumns(columns) |
284 | | - .setTableKeys(schema.primaryKeys()) |
285 | | - .setDistributionKeys(schema.primaryKeys()) |
286 | | - .setNumBuckets(10) |
287 | | - .setTableProperties(Collections.singletonMap("replication_num", "5")) |
288 | | - .build(); |
289 | | - Assertions.assertThat(actualTable).isEqualTo(expectTable); |
290 | | - } |
291 | 229 | } |
0 commit comments