Skip to content
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 @@ -371,6 +371,12 @@ private static Type convertScalarType(String typeName, int precision, int scale)
return ScalarType.createTimeStampTzType(precision);
}
return ScalarType.createTimeStampTzType(0);
case "TIMEV2":
// Like DATETIMEV2, connectors put the time scale in the precision field.
if (precision >= 0) {
return ScalarType.createTimeV2Type(precision);
}
return ScalarType.TIMEV2;
case "VARBINARY":
if (precision > 0) {
return ScalarType.createVarbinaryType(precision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@ void testDecimalTypeRoundtrip() {
Assertions.assertEquals(6, ct.getScale());
}

@Test
void timeScaleRidesInThePrecisionSlot() {
// Connectors put the TIMEV2 scale where they put the DATETIMEV2 one: hudi maps Avro time-millis
// and time-micros to ("TIMEV2", 3|6, 0), and lance maps Arrow time32(ms) / time64(us|ns) the same
// way. Dropping it shows time(3) as time and reads the column at second precision.
Assertions.assertEquals(ScalarType.createTimeV2Type(0),
ConnectorColumnConverter.convertType(ConnectorType.of("TIMEV2", 0, 0)));
Assertions.assertEquals(ScalarType.createTimeV2Type(3),
ConnectorColumnConverter.convertType(ConnectorType.of("TIMEV2", 3, 0)));
Assertions.assertEquals(ScalarType.createTimeV2Type(6),
ConnectorColumnConverter.convertType(ConnectorType.of("TIMEV2", 6, 0)));
Assertions.assertEquals("time(3)",
ConnectorColumnConverter.convertType(ConnectorType.of("TIMEV2", 3, 0)).toSql());
// No precision given: the scale-0 TIMEV2 it has always been.
Assertions.assertEquals(ScalarType.TIMEV2, ConnectorColumnConverter.convertType(ConnectorType.of("TIMEV2")));
}

@Test
void testWithTimeZoneColumnSetsExtraInfo() {
// A ConnectorColumn marked withTimeZone() must convert to a Doris Column carrying the
Expand Down
Loading