diff --git a/dfsclient/src/main/java/org/hpccsystems/dfs/client/BinaryRecordReader.java b/dfsclient/src/main/java/org/hpccsystems/dfs/client/BinaryRecordReader.java index 565a59454..58470fdd8 100644 --- a/dfsclient/src/main/java/org/hpccsystems/dfs/client/BinaryRecordReader.java +++ b/dfsclient/src/main/java/org/hpccsystems/dfs/client/BinaryRecordReader.java @@ -830,7 +830,15 @@ private BigDecimal getUnsignedDecimal(int numDigits, int precision, int dataLen) BigDecimal ret = new BigDecimal(0); int idx = 0; - int curDigit = numDigits - 1; + int curDigit = numDigits; + + // If the # of digits is odd the top most nibble is unused and we don't want to include it + // in the scale calculations below. Due to how the scale calculation works below this means + // we decrement the starting value of curDigit in the case of even length decimals + if ((numDigits % 2) == 0) + { + curDigit--; + } while (idx < dataLen) { diff --git a/dfsclient/src/test/resources/generate-datasets.ecl b/dfsclient/src/test/resources/generate-datasets.ecl index 0c1fdafa7..fed129a15 100644 --- a/dfsclient/src/test/resources/generate-datasets.ecl +++ b/dfsclient/src/test/resources/generate-datasets.ecl @@ -10,7 +10,10 @@ childRec := {STRING8 childField1, INTEGER8 childField2, REAL8 childField3}; rec := {INTEGER8 int8, UNSIGNED8 uint8, INTEGER4 int4, UNSIGNED4 uint4, INTEGER2 int2, UNSIGNED2 uint2, REAL8 r8, REAL4 r4, - DECIMAL16_8 dec16, UDECIMAL16_8 udec16, + DECIMAL16_8 dec16, + DECIMAL15_8 dec15, + UDECIMAL16_8 udec16, + UDECIMAL15_8 udec15, QSTRING qStr, STRING8 fixStr8, STRING str, @@ -33,7 +36,9 @@ ds := DATASET(totalrecs1, transform(rec, self.r8 := (REAL)(random() % unique_values); self.r4 := (REAL)(random() % unique_values); self.dec16 := (REAL)(random() % unique_values); + self.dec15 := (REAL)(random() % unique_values); self.udec16 := (REAL)(random() % unique_values); + self.udec15 := (REAL)(random() % unique_values); self.qStr := (STRING)(random() % unique_values); self.fixStr8 := (STRING)(random() % unique_values); self.str := (STRING)(random() % unique_values);