Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Added a few more tests for Decimal to String cast #9818

Merged
merged 2 commits into from
Dec 3, 2021
Merged
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
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"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test case for a negative decimal value greater than 64 bits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that will accomplish is to verify that Java BigDecimals > 64 bit have precision > 38

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make sure that this didn't leak?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously we should!

if (cv != null) {
cv.close();
}
Comment on lines +3397 to +3399
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not try(....cv = ..) {}? It is auto-closed, isn't it?

fail("Precision check should've thrown an IllegalArgumentException");
} catch (IllegalArgumentException iae) {
}
}

@Test
Expand Down