|
33 | 33 | import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;
|
34 | 34 | import org.apache.seatunnel.connectors.doris.config.DorisOptions;
|
35 | 35 | import org.apache.seatunnel.connectors.doris.datatype.DorisTypeConverterV1;
|
| 36 | +import org.apache.seatunnel.connectors.doris.datatype.DorisTypeConverterV2; |
36 | 37 | import org.apache.seatunnel.connectors.doris.util.DorisCatalogUtil;
|
37 | 38 |
|
38 | 39 | import org.apache.commons.lang3.StringUtils;
|
@@ -389,7 +390,45 @@ public void testWithThreePrimaryKeys() {
|
389 | 390 | + "`comment` VARCHAR(500) NULL ,\n"
|
390 | 391 | + "`description` STRING NULL \n"
|
391 | 392 | + " )\n"
|
392 |
| - + " partitioned by `id`,`age`,`name`;", |
| 393 | + + " partitioned by `id`,`name`,`age`;", |
| 394 | + result); |
| 395 | + } |
| 396 | + |
| 397 | + @Test |
| 398 | + public void testWithResortedMultiPrimaryKey() { |
| 399 | + List<Column> columns = new ArrayList<>(); |
| 400 | + |
| 401 | + columns.add(PhysicalColumn.of("id", BasicType.LONG_TYPE, (Long) null, true, null, "")); |
| 402 | + columns.add(PhysicalColumn.of("name", BasicType.STRING_TYPE, (Long) null, true, null, "")); |
| 403 | + columns.add(PhysicalColumn.of("age", BasicType.INT_TYPE, (Long) null, true, null, "")); |
| 404 | + |
| 405 | + String result = |
| 406 | + DorisCatalogUtil.getCreateTableStatement( |
| 407 | + DorisOptions.SAVE_MODE_CREATE_TEMPLATE.defaultValue(), |
| 408 | + TablePath.of("test1", "test2"), |
| 409 | + CatalogTable.of( |
| 410 | + TableIdentifier.of("test", "test1", "test2"), |
| 411 | + TableSchema.builder() |
| 412 | + .primaryKey(PrimaryKey.of("", Arrays.asList("age", "id"))) |
| 413 | + .columns(columns) |
| 414 | + .build(), |
| 415 | + Collections.emptyMap(), |
| 416 | + Collections.emptyList(), |
| 417 | + ""), |
| 418 | + DorisTypeConverterV2.INSTANCE); |
| 419 | + Assertions.assertEquals( |
| 420 | + "CREATE TABLE IF NOT EXISTS `test1`.`test2` (\n" |
| 421 | + + "`id` BIGINT NULL ,`age` INT NULL ,\n" |
| 422 | + + "`name` STRING NULL \n" |
| 423 | + + ") ENGINE=OLAP\n" |
| 424 | + + " UNIQUE KEY (`id`,`age`)\n" |
| 425 | + + "DISTRIBUTED BY HASH (`id`,`age`)\n" |
| 426 | + + " PROPERTIES (\n" |
| 427 | + + "\"replication_allocation\" = \"tag.location.default: 1\",\n" |
| 428 | + + "\"in_memory\" = \"false\",\n" |
| 429 | + + "\"storage_format\" = \"V2\",\n" |
| 430 | + + "\"disable_auto_compaction\" = \"false\"\n" |
| 431 | + + ")", |
393 | 432 | result);
|
394 | 433 | }
|
395 | 434 | }
|
0 commit comments