diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index bce330ea4a3..4efac307627 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -936,6 +936,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas break; case cudf::type_id::DECIMAL32: case cudf::type_id::DECIMAL64: + case cudf::type_id::DECIMAL128: result = cudf::strings::to_fixed_point(*column, n_data_type); break; default: JNI_THROW_NEW(env, "java/lang/IllegalArgumentException", "Invalid data type", 0); diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index f332661dc19..a582541a0d4 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -3370,6 +3370,22 @@ void testFixedWidthCast() { } } + @Test + void testCastStringToBigDecimal() { + String[] bigValues = {"923121331938210123.321", + "9223372036854775808.191", + "9328323982309091029831.002" + }; + + try (ColumnVector cv = ColumnVector.fromStrings(bigValues); + ColumnVector values = cv.castTo(DType.create(DType.DTypeEnum.DECIMAL128, -3)); + ColumnVector expected = ColumnVector.fromDecimals(new BigDecimal("923121331938210123.321"), + new BigDecimal("9223372036854775808.191"), + new BigDecimal("9328323982309091029831.002"))) { + assertColumnsAreEqual(expected, values); + } + } + @Test void testCastByteToString() {