Author: jitendra
Date: Tue Mar 11 18:25:50 2014
New Revision: 1576455
URL: http://svn.apache.org/r1576455
Log:
HIVE-6594: UnsignedInt128 addition does not increase internal int array count
resulting in corrupted values during serialization (Remus Rusanu)
Modified:
hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java
hive/branches/branch-0.13/ql/src/test/results/clientpositive/vector_decimal_aggregate.q.out
hive/branches/branch-0.13/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveDecimalWritable.java
Modified:
hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java
URL:
http://svn.apache.org/viewvc/hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java?rev=1576455&r1=1576454&r2=1576455&view=diff
==============================================================================
---
hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java
(original)
+++
hive/branches/branch-0.13/common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java
Tue Mar 11 18:25:50 2014
@@ -2002,6 +2002,8 @@ public final class UnsignedInt128 implem
SqlMathUtil.throwOverflowException();
}
+ result.updateCount();
+
return cmp > 0 ? (byte) 1 : (byte) -1;
}
Modified:
hive/branches/branch-0.13/ql/src/test/results/clientpositive/vector_decimal_aggregate.q.out
URL:
http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/results/clientpositive/vector_decimal_aggregate.q.out?rev=1576455&r1=1576454&r2=1576455&view=diff
==============================================================================
---
hive/branches/branch-0.13/ql/src/test/results/clientpositive/vector_decimal_aggregate.q.out
(original)
+++
hive/branches/branch-0.13/ql/src/test/results/clientpositive/vector_decimal_aggregate.q.out
Tue Mar 11 18:25:50 2014
@@ -100,7 +100,7 @@ POSTHOOK: type: QUERY
POSTHOOK: Input: default@decimal_vgby
#### A masked pattern was here ####
NULL 3072 9318.4351351351 -4298.1513513514 5018444.1081079808
1633.60810810806667 5695.4830821353335 5696.410307714474 3072
11160.715384615385 -5147.907692307693 6010604.3076923073536
1956.576923076922966667 6821.495748565141 6822.606289190906
--3728 6 5831542.269248378 -3367.6517567568
5817556.0411483778 969592.67352472963333 2174330.2092403853
2381859.406131774 6 6984454.211097692 -4033.445769230769
6967702.8672438458471 23734.593328551958196667 2604201.2704476737
2852759.5602156054
+-3728 6 5831542.269248378 -3367.6517567568
5817556.0411483778 969592.67352472963333 2174330.2092403853
2381859.406131774 6 6984454.211097692 -4033.445769230769
6967702.8672438458471 1161283.811207307641183333 2604201.2704476737
2852759.5602156054
-563 2 -515.621072973 -3367.6517567568 -3883.2728297298
-1941.6364148649 1426.0153418919 2016.6902366556312 2
-617.5607769230769 -4033.445769230769 -4651.0065461538459
-2325.50327307692295 1707.9424961538462 2415.395441814127
762 2 5831542.269248378 1531.2194054054 5833073.4886537834
2916536.7443268917 2915005.524921486 4122440.347736469 2
6984454.211097692 1833.9456923076925 6986288.1567899996925
3493144.07839499984625 3491310.132702692 4937458.140118757
6981 3 5831542.269248378 -515.621072973 5830511.027102432
1943503.67570081066667 2749258.4550124914 3367140.192906513 3
6984454.211097692 -617.5607769230769 6983219.0895438458462
2327739.696514615282066667 3292794.4113115156 4032833.0678006653
Modified:
hive/branches/branch-0.13/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveDecimalWritable.java
URL:
http://svn.apache.org/viewvc/hive/branches/branch-0.13/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveDecimalWritable.java?rev=1576455&r1=1576454&r2=1576455&view=diff
==============================================================================
---
hive/branches/branch-0.13/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveDecimalWritable.java
(original)
+++
hive/branches/branch-0.13/serde/src/test/org/apache/hadoop/hive/serde2/io/TestHiveDecimalWritable.java
Tue Mar 11 18:25:50 2014
@@ -216,5 +216,28 @@ public class TestHiveDecimalWritable {
doTestFastStreamForHiveDecimal(value.toFormalString());
}
+ @Test
+ public void testHive6594() {
+ String[] vs = new String[] {
+ "-4033.445769230769",
+ "6984454.211097692"};
+
+ Decimal128 d = new Decimal128(0L, (short) 14);
+ for (String s:vs) {
+ Decimal128 p = new Decimal128(s, (short) 14);
+ d.addDestructive(p, (short) (short) 14);
+ }
+
+ int bufferUsed = d.fastSerializeForHiveDecimal(scratch);
+ HiveDecimalWritable hdw = new HiveDecimalWritable();
+ hdw.set(scratch.getBytes(bufferUsed), d.getScale());
+
+ HiveDecimal hd = hdw.getHiveDecimal();
+
+ BigDecimal readValue = hd.bigDecimalValue();
+
+ Assert.assertEquals(d.toBigDecimal().stripTrailingZeros(),
+ readValue.stripTrailingZeros());
+ }
}