Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-36351][pipeline-connector/doris] support the conversion of Flink TIME type to Doris String typeAdd the conversion from Flink TIME type to Doris. #3620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Arrays;
Expand Down Expand Up @@ -116,6 +117,8 @@ static SerializationConverter createExternalConverter(DataType type, ZoneId pipe
case TIMESTAMP_WITH_TIME_ZONE:
final int zonedP = ((ZonedTimestampType) type).getPrecision();
return (index, val) -> val.getTimestamp(index, zonedP).toTimestamp();
case TIME_WITHOUT_TIME_ZONE:
return (index, val) -> LocalTime.ofNanoOfDay(val.getLong(index) * 1_000_000L);
case ARRAY:
return (index, val) -> convertArrayData(val.getArray(index), type);
case MAP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,14 @@ public void testDorisDataTypes() throws Exception {
.column(new PhysicalColumn("string", DataTypes.STRING(), "String"))
.column(new PhysicalColumn("decimal", DataTypes.DECIMAL(17, 7), "Decimal"))
.column(new PhysicalColumn("date", DataTypes.DATE(), "Date"))
// Doris sink doesn't support TIME type yet.
// .column(new PhysicalColumn("time", DataTypes.TIME(), "Time"))
// .column(new PhysicalColumn("time_3", DataTypes.TIME(3), "Time With
// Precision"))
// Doris sink doesn't support TIME type ,thus convert TIME to STRING
.column(new PhysicalColumn("time", DataTypes.TIME(), "Time"))
.column(
new PhysicalColumn(
"time_3", DataTypes.TIME(3), "Time With Precision"))
.column(
new PhysicalColumn(
"time_6", DataTypes.TIME(6), "Time With Precision"))
.column(new PhysicalColumn("timestamp", DataTypes.TIMESTAMP(), "Timestamp"))
.column(
new PhysicalColumn(
Expand Down Expand Up @@ -296,6 +300,9 @@ public void testDorisDataTypes() throws Exception {
"string | TEXT | Yes | false | null",
"decimal | DECIMAL(17, 7) | Yes | false | null",
"date | DATE | Yes | false | null",
"time | TEXT | Yes | false | null",
"time_3 | TEXT | Yes | false | null",
"time_6 | TEXT | Yes | false | null",
"timestamp | DATETIME(6) | Yes | false | null",
"timestamp_3 | DATETIME(3) | Yes | false | null",
"timestamptz | DATETIME(6) | Yes | false | null",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public void testExternalConvert() {
Column.physicalColumn("f19", DataTypes.TIMESTAMP()),
Column.physicalColumn("f20", DataTypes.TIMESTAMP_LTZ()),
Column.physicalColumn("f21", DataTypes.TIMESTAMP_LTZ()),
Column.physicalColumn("f22", DataTypes.TIMESTAMP_LTZ()));
Column.physicalColumn("f22", DataTypes.TIMESTAMP_LTZ()),
Column.physicalColumn("f23", DataTypes.TIME(0)),
Column.physicalColumn("f24", DataTypes.TIME(3)),
Column.physicalColumn("f24", DataTypes.TIME(6)));

List<DataType> dataTypes =
columns.stream().map(v -> v.getType()).collect(Collectors.toList());
Expand Down Expand Up @@ -104,6 +107,9 @@ public void testExternalConvert() {
LocalZonedTimestampData.fromInstant(f20),
LocalZonedTimestampData.fromInstant(f21),
LocalZonedTimestampData.fromInstant(f22),
3661000,
3661123,
3661123
});
List row = new ArrayList();
for (int i = 0; i < recordData.getArity(); i++) {
Expand All @@ -115,7 +121,7 @@ public void testExternalConvert() {
Assert.assertEquals(
"[true, 1.2, 1.2345, 1, 32, 64, 128, 2021-01-01 08:00:00.000000, 2021-01-01, a, doris, 2021-01-01 "
+ "08:01:11.000000, 2021-01-01 08:01:11.123000, 2021-01-01 08:01:11.123456, 2021-01-01 "
+ "16:01:11.000000, 2021-01-01 16:01:11.123000, 2021-01-01 16:01:11.123456]",
+ "16:01:11.000000, 2021-01-01 16:01:11.123000, 2021-01-01 16:01:11.123456, 01:01:01, 01:01:01.123, 01:01:01.123]",
row.toString());
}
}
Loading