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 @@ -731,8 +731,7 @@ private static Duration textDecodeTime(int collationId, ByteBuf buffer, int inde
int second = Integer.parseInt(timeElements[2].substring(0, 2));
long nanos = 0;
if (timeElements[2].length() > 2) {
double fractionalSecondsPart = Double.parseDouble("0." + timeElements[2].substring(3));
nanos = (long) (1000000000 * fractionalSecondsPart);
nanos = Long.parseLong((timeElements[2].substring(3) + "00000000").substring(0, 9));
}
if (isNegative) {
return Duration.ofHours(-hour).minusMinutes(minute).minusSeconds(second).minusNanos(nanos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public void testDecodeFractionalSecondsPart(TestContext ctx) {
testDecodeGeneric(ctx, "11:12:00.123456", "TIME(6)", "test_time", Duration.ofHours(11).plusMinutes(12).plusNanos(123456000));
}

@Test
public void testDecodeSmallFractionalSecondsPart(TestContext ctx) {
testDecodeGeneric(ctx, "11:12:00.000065", "TIME(6)", "test_time", Duration.ofHours(11).plusMinutes(12).plusNanos(65000));
}

@Test
public void testDecodeTimeAsLocalTimeWithFractionalSecondsPart(TestContext ctx) {
testDecodeGeneric(ctx, "11:12:00.123456", "TIME(6)", row -> {
Expand Down