Skip to content

Commit

Permalink
Added a few more tests for Decimal to String cast (#9818)
Browse files Browse the repository at this point in the history
This PR adds a few more edge cases as a sanity test on the request of @sameerz

Authors:
  - Raza Jafri (https://github.com/razajafri)

Approvers:
  - Robert (Bobby) Evans (https://github.com/revans2)

URL: #9818
  • Loading branch information
razajafri authored Dec 3, 2021
1 parent 50e22ab commit 62103c6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3376,16 +3376,30 @@ void testFixedWidthCast() {
void testCastBigDecimalToString() {
BigDecimal[] bigValues = {new BigDecimal("923121331938210123.321"),
new BigDecimal("9223372036854775808.191"),
new BigDecimal("-9.223"),
new BigDecimal("0.000"),
new BigDecimal("9328323982309091029831.002")
};

try (ColumnVector cv = ColumnVector.fromDecimals(bigValues);
ColumnVector values = cv.castTo(DType.STRING);
ColumnVector expected = ColumnVector.fromStrings("923121331938210123.321",
"9223372036854775808.191",
"9328323982309091029831.002")) {
"-9.223",
"0.000",
"9328323982309091029831.002")) {
assertColumnsAreEqual(expected, values);
}

BigDecimal[] bigValues0 = {new BigDecimal("992983283728193827182918744829283742232")};
try {
ColumnVector cv = ColumnVector.fromDecimals(bigValues0);
if (cv != null) {
cv.close();
}
fail("Precision check should've thrown an IllegalArgumentException");
} catch (IllegalArgumentException iae) {
}
}

@Test
Expand Down

0 comments on commit 62103c6

Please sign in to comment.