Skip to content

Commit cf398ad

Browse files
Add test for SECOND truncation of sub-second precision
1 parent 6d63367 commit cf398ad

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverterTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,20 @@ public void testBindParameterSecTZVector() {
152152
assertEquals(EPOCH_MILLIS / 1_000L, vector.get(0));
153153
}
154154
}
155+
156+
@Test
157+
public void testBindParameterSecVectorTruncatesSubSecond() {
158+
BufferAllocator allocator = rootAllocatorTestExtension.getRootAllocator();
159+
ArrowType.Timestamp type = new ArrowType.Timestamp(TimeUnit.SECOND, null);
160+
TimestampAvaticaParameterConverter converter = new TimestampAvaticaParameterConverter(type);
161+
162+
try (TimeStampSecVector vector = new TimeStampSecVector("ts", allocator)) {
163+
vector.allocateNew(1);
164+
// 1999 millis should truncate to 1 second, not round to 2
165+
long millis = 1999L;
166+
TypedValue typedValue = TypedValue.ofLocal(ColumnMetaData.Rep.JAVA_SQL_TIMESTAMP, millis);
167+
assertTrue(converter.bindParameter(vector, typedValue, 0));
168+
assertEquals(1L, vector.get(0));
169+
}
170+
}
155171
}

0 commit comments

Comments
 (0)