Skip to content

Commit

Permalink
Revert unrelated changes
Browse files Browse the repository at this point in the history
Signed-off-by: Nghia Truong <[email protected]>
  • Loading branch information
ttnghia committed Jul 20, 2024
1 parent 30b80e0 commit 8607d14
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions src/main/java/com/nvidia/spark/rapids/jni/DecimalUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ public class DecimalUtils {
* Multiply two DECIMAL128 columns together into a DECIMAL128 product rounded to the specified
* scale with overflow detection. This method considers a precision greater than 38 as overflow
* even if the number still fits in a 128-bit representation.
* <p>
*
* WARNING: This method has a bug which we match with Spark versions before 3.4.2,
* 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale
* of 10:
* -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533
* .575166
* 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale of 10:
* -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533.575166
* while the actual answer based on Java BigDecimal is 102401338377036577293248132533.575165
*
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param productScale scale to use for the product type
* @return table containing a boolean column and a DECIMAL128 product column of the specified
* scale. The boolean value will be true if an overflow was detected for that row's
Expand All @@ -55,28 +53,23 @@ public static Table multiply128(ColumnView a, ColumnView b, int productScale) {
* Multiply two DECIMAL128 columns together into a DECIMAL128 product rounded to the specified
* scale with overflow detection. This method considers a precision greater than 38 as overflow
* even if the number still fits in a 128-bit representation.
* <p>
* WARNING: With interimCast set to true, this method has a bug which we match with Spark
* versions before 3.4.2,
* 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale
* of 10:
* -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533
* .575166
*
* WARNING: With interimCast set to true, this method has a bug which we match with Spark versions before 3.4.2,
* 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale of 10:
* -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533.575166
* while the actual answer based on Java BigDecimal is 102401338377036577293248132533.575165
*
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param productScale scale to use for the product type
* @param interimCast whether to cast the result of the division to 38 precision before
* casting it again to the final
* precision
* @param interimCast whether to cast the result of the division to 38 precision before casting it again to the final
* precision
* @return table containing a boolean column and a DECIMAL128 product column of the specified
* scale. The boolean value will be true if an overflow was detected for that row's
* DECIMAL128 product value. A null input row will result in a corresponding null output
* row.
*/
public static Table multiply128(ColumnView a, ColumnView b, int productScale,
boolean interimCast) {
public static Table multiply128(ColumnView a, ColumnView b, int productScale, boolean interimCast) {
return new Table(multiply128(a.getNativeView(), b.getNativeView(), productScale, interimCast));
}

Expand All @@ -85,8 +78,8 @@ public static Table multiply128(ColumnView a, ColumnView b, int productScale,
* scale with overflow detection. This method considers a precision greater than 38 as overflow
* even if the number still fits in a 128-bit representation.
*
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param quotientScale scale to use for the quotient type
* @return table containing a boolean column and a DECIMAL128 quotient column of the specified
* scale. The boolean value will be true if an overflow was detected for that row's
Expand Down Expand Up @@ -123,12 +116,12 @@ public static Table integerDivide128(ColumnView a, ColumnView b) {
* Divide two DECIMAL128 columns and produce a DECIMAL128 remainder with overflow detection.
* Example:
* 451635271134476686911387864.48 % -961.110 = 775.233
* <p>
*
* Generally, this will never really overflow unless in the divide by zero case.
* But it will detect an overflow in any case.
*
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param a factor input, must match row count of the other factor input
* @param b factor input, must match row count of the other factor input
* @param remainderScale scale to use for the remainder type
* @return table containing a boolean column and a DECIMAL128 remainder column.
* The boolean value will be true if an overflow was detected for that row's
Expand All @@ -143,12 +136,12 @@ public static Table remainder128(ColumnView a, ColumnView b, int remainderScale)
* Subtract two DECIMAL128 columns and produce a DECIMAL128 result rounded to the specified
* scale with overflow detection. This method considers a precision greater than 38 as overflow
* even if the number still fits in a 128-bit representation.
* <p>
*
* NOTE: This is very specific to Spark 3.4. This method is incompatible with previous versions
* of Spark. We don't need this for versions prior to Spark 3.4
*
* @param a input, must match row count of the other input
* @param b input, must match row count of the other input
* @param a input, must match row count of the other input
* @param b input, must match row count of the other input
* @param targetScale scale to use for the result
* @return table containing a boolean column and a DECIMAL128 result column of the specified
* scale. The boolean value will be true if an overflow was detected for that row's
Expand All @@ -168,12 +161,12 @@ public static Table subtract128(ColumnView a, ColumnView b, int targetScale) {
* Add two DECIMAL128 columns and produce a DECIMAL128 result rounded to the specified
* scale with overflow detection. This method considers a precision greater than 38 as overflow
* even if the number still fits in a 128-bit representation.
* <p>
*
* NOTE: This is very specific to Spark 3.4. This method is incompatible with previous versions
* of Spark. We don't need this for versions prior to Spark 3.4
*
* @param a input, must match row count of the other input
* @param b input, must match row count of the other input
* @param a input, must match row count of the other input
* @param b input, must match row count of the other input
* @param targetScale scale to use for the sum
* @return table containing a boolean column and a DECIMAL128 sum column of the specified
* scale. The boolean value will be true if an overflow was detected for that row's
Expand Down Expand Up @@ -207,7 +200,7 @@ public CastFloatToDecimalResult(ColumnVector result, boolean hasFailure) {
/**
* Cast floating point values to decimals, matching the behavior of Spark.
*
* @param input The input column, which is either FLOAT32 or FLOAT64
* @param input The input column, which is either FLOAT32 or FLOAT64
* @param outputType The output decimal type
* @return The decimal column resulting from the cast operation and a boolean column indicating
* whether the cast operation has failed for any input rows
Expand Down

0 comments on commit 8607d14

Please sign in to comment.