|
|
|
@ -21,6 +21,7 @@ import org.apache.flink.api.common.restartstrategy.RestartStrategies;
|
|
|
|
|
import org.apache.flink.api.common.typeinfo.TypeInformation;
|
|
|
|
|
import org.apache.flink.api.connector.sink2.Sink;
|
|
|
|
|
import org.apache.flink.cdc.common.configuration.Configuration;
|
|
|
|
|
import org.apache.flink.cdc.common.data.LocalZonedTimestampData;
|
|
|
|
|
import org.apache.flink.cdc.common.data.binary.BinaryStringData;
|
|
|
|
|
import org.apache.flink.cdc.common.event.CreateTableEvent;
|
|
|
|
|
import org.apache.flink.cdc.common.event.DataChangeEvent;
|
|
|
|
@ -42,6 +43,7 @@ import org.junit.Before;
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -84,7 +86,11 @@ public class DorisPipelineITCase extends DorisSinkTestBase {
|
|
|
|
|
DorisContainer.DORIS_DATABASE_NAME,
|
|
|
|
|
DorisContainer.DORIS_TABLE_NAME,
|
|
|
|
|
"id",
|
|
|
|
|
Arrays.asList("id INT NOT NULL", "number DOUBLE", "name VARCHAR(51)"));
|
|
|
|
|
Arrays.asList(
|
|
|
|
|
"id INT NOT NULL",
|
|
|
|
|
"number DOUBLE",
|
|
|
|
|
"name VARCHAR(51)",
|
|
|
|
|
"birthday DATETIMEV2(6)"));
|
|
|
|
|
|
|
|
|
|
// waiting for table to be created
|
|
|
|
|
DORIS_CONTAINER.waitForLog(
|
|
|
|
@ -135,41 +141,76 @@ public class DorisPipelineITCase extends DorisSinkTestBase {
|
|
|
|
|
.column(new PhysicalColumn("id", DataTypes.INT().notNull(), null))
|
|
|
|
|
.column(new PhysicalColumn("number", DataTypes.DOUBLE(), null))
|
|
|
|
|
.column(new PhysicalColumn("name", DataTypes.VARCHAR(17), null))
|
|
|
|
|
.column(new PhysicalColumn("birthday", DataTypes.TIMESTAMP_LTZ(6), null))
|
|
|
|
|
.primaryKey("id")
|
|
|
|
|
.build();
|
|
|
|
|
BinaryRecordDataGenerator generator =
|
|
|
|
|
new BinaryRecordDataGenerator(
|
|
|
|
|
RowType.of(DataTypes.INT(), DataTypes.DOUBLE(), DataTypes.VARCHAR(17)));
|
|
|
|
|
RowType.of(
|
|
|
|
|
DataTypes.INT(),
|
|
|
|
|
DataTypes.DOUBLE(),
|
|
|
|
|
DataTypes.VARCHAR(17),
|
|
|
|
|
DataTypes.TIMESTAMP_LTZ(6)));
|
|
|
|
|
|
|
|
|
|
return Arrays.asList(
|
|
|
|
|
new CreateTableEvent(tableId, schema),
|
|
|
|
|
DataChangeEvent.insertEvent(
|
|
|
|
|
tableId,
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {17, 3.14, BinaryStringData.fromString("Doris Day")})),
|
|
|
|
|
new Object[] {
|
|
|
|
|
17,
|
|
|
|
|
3.14,
|
|
|
|
|
BinaryStringData.fromString("Doris Day"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
})),
|
|
|
|
|
DataChangeEvent.insertEvent(
|
|
|
|
|
tableId,
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {
|
|
|
|
|
19, 2.718, BinaryStringData.fromString("Que Sera Sera")
|
|
|
|
|
19,
|
|
|
|
|
2.718,
|
|
|
|
|
BinaryStringData.fromString("Que Sera Sera"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
})),
|
|
|
|
|
DataChangeEvent.insertEvent(
|
|
|
|
|
tableId,
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {
|
|
|
|
|
21, 1.732, BinaryStringData.fromString("Disenchanted")
|
|
|
|
|
21,
|
|
|
|
|
1.732,
|
|
|
|
|
BinaryStringData.fromString("Disenchanted"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
})),
|
|
|
|
|
DataChangeEvent.updateEvent(
|
|
|
|
|
tableId,
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {17, 3.14, BinaryStringData.fromString("Doris Day")}),
|
|
|
|
|
new Object[] {
|
|
|
|
|
17,
|
|
|
|
|
3.14,
|
|
|
|
|
BinaryStringData.fromString("Doris Day"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
}),
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {17, 6.28, BinaryStringData.fromString("Doris Day")})),
|
|
|
|
|
new Object[] {
|
|
|
|
|
17,
|
|
|
|
|
6.28,
|
|
|
|
|
BinaryStringData.fromString("Doris Day"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
})),
|
|
|
|
|
DataChangeEvent.deleteEvent(
|
|
|
|
|
tableId,
|
|
|
|
|
generator.generate(
|
|
|
|
|
new Object[] {
|
|
|
|
|
19, 2.718, BinaryStringData.fromString("Que Sera Sera")
|
|
|
|
|
19,
|
|
|
|
|
2.718,
|
|
|
|
|
BinaryStringData.fromString("Que Sera Sera"),
|
|
|
|
|
LocalZonedTimestampData.fromInstant(
|
|
|
|
|
Instant.parse("2023-01-01T00:00:00.000Z"))
|
|
|
|
|
})));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -201,9 +242,12 @@ public class DorisPipelineITCase extends DorisSinkTestBase {
|
|
|
|
|
|
|
|
|
|
env.execute("Values to Doris Sink");
|
|
|
|
|
|
|
|
|
|
List<String> actual = fetchTableContent(tableId, 3);
|
|
|
|
|
List<String> actual = fetchTableContent(tableId, 4);
|
|
|
|
|
|
|
|
|
|
List<String> expected = Arrays.asList("17 | 6.28 | Doris Day", "21 | 1.732 | Disenchanted");
|
|
|
|
|
List<String> expected =
|
|
|
|
|
Arrays.asList(
|
|
|
|
|
"17 | 6.28 | Doris Day | 2023-01-01 00:00:00",
|
|
|
|
|
"21 | 1.732 | Disenchanted | 2023-01-01 00:00:00");
|
|
|
|
|
|
|
|
|
|
assertEqualsInAnyOrder(expected, actual);
|
|
|
|
|
}
|
|
|
|
|