Skip to content
Merged
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 @@ -512,7 +512,10 @@ static String handleRecordFieldType(String fieldName, GenericRecord element, Sch
// Convert to timestamp string.
Long totalMicros = TimeUnit.DAYS.toMicros(Long.valueOf(element.get("date").toString()));
totalMicros += Long.valueOf(element.get("time").toString());
Instant timestamp = Instant.ofEpochSecond(TimeUnit.MICROSECONDS.toSeconds(totalMicros));
Instant timestamp =
Instant.ofEpochSecond(
TimeUnit.MICROSECONDS.toSeconds(totalMicros),
TimeUnit.MICROSECONDS.toNanos(totalMicros % TimeUnit.SECONDS.toMicros(1)));
return timestamp.atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
} else if (fieldSchema.getName().equals("interval")) {
// TODO: For MySQL, we ignore the months field. This might require source-specific handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ public void testHandleRecordFieldType() {
result =
GenericRecordTypeConvertor.handleRecordFieldType(
"date_time_column",
AvroTestingHelper.createDatetimeRecord(738991, 48035000000L),
AvroTestingHelper.createDatetimeRecord(20091, 31703699206L),
AvroTestingHelper.DATETIME_SCHEMA);
assertEquals("Test datetime conversion: ", "3993-04-16T13:20:35Z", result);
assertEquals("Test datetime conversion: ", "2025-01-03T08:48:23.699206Z", result);

// Tests for interval type.
result =
Expand Down
Loading