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 @@ -1380,7 +1380,7 @@ private static org.apache.avro.Schema getFieldSchema(
return Days.daysBetween(Instant.EPOCH, (Instant) value).getDays();
} else if (SqlTypes.DATE.getIdentifier().equals(identifier)) {
// portable SqlTypes.DATE is backed by java.time.LocalDate
return ((java.time.LocalDate) value).toEpochDay();
return (int) ((java.time.LocalDate) value).toEpochDay();
} else if ("TIME".equals(identifier)) {
return (int) ((Instant) value).getMillis();
} else if (SqlTypes.TIMESTAMP.getIdentifier().equals(identifier)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,9 @@ public void testSqlTypesToGenericRecord() {

org.apache.avro.Schema avroSchema = AvroUtils.toAvroSchema(beamSchema);
GenericRecord expectedRecord =
new GenericRecordBuilder(avroSchema).set("local_date", localDate.toEpochDay()).build();
new GenericRecordBuilder(avroSchema)
.set("local_date", (int) localDate.toEpochDay())
.build();

assertEquals(expectedRecord, AvroUtils.toGenericRecord(rowData, avroSchema));
}
Expand Down
Loading