Skip to content

Commit 1b15100

Browse files
Throw an error on overflow in date milli producer
1 parent 05f0b8f commit 1b15100

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

adapter/avro/src/main/java/org/apache/arrow/adapter/avro/producers/logical/AvroDateMilliProducer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public AvroDateMilliProducer(DateMilliVector vector) {
4040
public void produce(Encoder encoder) throws IOException {
4141
long millis = vector.getDataBuffer().getLong(currentIndex * (long) DateMilliVector.TYPE_WIDTH);
4242
long days = millis / MILLIS_PER_DAY;
43+
if (days > (long) Integer.MAX_VALUE || days < (long) Integer.MIN_VALUE) {
44+
throw new ArithmeticException("Date value is too large for Avro encoding");
45+
}
4346
encoder.writeInt((int) days);
4447
currentIndex++;
4548
}

0 commit comments

Comments
 (0)