Skip to content

Commit 614ad61

Browse files
committed
test: fix Decimal accessor row round-trip checks
Initialize both UnsafeRowWriter instances before writing and verify that each row reads back the expected Decimal. Add braces around the small Decimal null check. Signed-off-by: Peifeng Li <[email protected]>
1 parent f4185cd commit 614ad61

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎java/vortex-spark/src/main/java/dev/vortex/spark/read/VortexArrowColumnVector.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ static final class SmallDecimalAccessor extends VortexArrowColumnVector.ArrowVec
579579

580580
@Override
581581
final Decimal getDecimal(int rowId, int precision, int scale) {
582-
if (isNullAt(rowId)) return null;
582+
if (isNullAt(rowId)) {
583+
return null;
584+
}
583585
long offset = (long) rowId * DecimalVector.TYPE_WIDTH;
584586
long unscaled = accessor.getDataBuffer().getLong(offset + lowWordOffset);
585587
long high = accessor.getDataBuffer().getLong(offset + highWordOffset);

‎java/vortex-spark/src/test/java/dev/vortex/spark/read/VortexDecimalAccessorTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,12 @@ private static void assertEquivalent(Decimal expected, Decimal actual, int preci
304304
assertEquals(expectedCopy.toJavaBigDecimal(), actualCopy.toJavaBigDecimal());
305305
UnsafeRowWriter expectedWriter = new UnsafeRowWriter(1);
306306
UnsafeRowWriter actualWriter = new UnsafeRowWriter(1);
307+
expectedWriter.resetRowWriter();
308+
actualWriter.resetRowWriter();
307309
expectedWriter.write(0, expected, precision, scale);
308310
actualWriter.write(0, actual, precision, scale);
311+
assertEquals(expected, expectedWriter.getRow().getDecimal(0, precision, scale));
312+
assertEquals(actual, actualWriter.getRow().getDecimal(0, precision, scale));
309313
assertEquals(expectedWriter.getRow(), actualWriter.getRow());
310314
}
311315
}

0 commit comments

Comments
 (0)