hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gunt...@apache.org
Subject svn commit: r1636055 [3/12] - in /hive/branches/branch-0.14: common/src/java/org/apache/hadoop/hive/common/type/ itests/src/test/resources/ ql/src/gen/vectorization/ExpressionTemplates/ ql/src/gen/vectorization/UDAFTemplates/ ql/src/java/org/apache/had...
Date Sat, 01 Nov 2014 21:10:34 GMT
Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorGroupByOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorGroupByOperator.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorGroupByOperator.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorGroupByOperator.java Sat Nov  1 21:10:32 2014
@@ -38,7 +38,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.hadoop.hive.common.type.Decimal128;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.util.FakeCaptureOutputOperator;
 import org.apache.hadoop.hive.ql.exec.vector.util.FakeVectorRowBatchFromConcat;
@@ -632,9 +631,9 @@ public class TestVectorGroupByOperator {
         "count",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(1),
-                new Decimal128(2),
-                new Decimal128(3)}),
+                HiveDecimal.create(1),
+                HiveDecimal.create(2),
+                HiveDecimal.create(3)}),
        3L);
   }
 
@@ -645,28 +644,28 @@ public class TestVectorGroupByOperator {
         "max",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(1),
-                new Decimal128(2),
-                new Decimal128(3)}),
-       new Decimal128(3));
+                HiveDecimal.create(1),
+                HiveDecimal.create(2),
+                HiveDecimal.create(3)}),
+       HiveDecimal.create(3));
     testAggregateDecimal(
         "Decimal",
         "max",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(3),
-                new Decimal128(2),
-                new Decimal128(1)}),
-        new Decimal128(3));
+                HiveDecimal.create(3),
+                HiveDecimal.create(2),
+                HiveDecimal.create(1)}),
+        HiveDecimal.create(3));
     testAggregateDecimal(
         "Decimal",
         "max",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(2),
-                new Decimal128(3),
-                new Decimal128(1)}),
-        new Decimal128(3));
+                HiveDecimal.create(2),
+                HiveDecimal.create(3),
+                HiveDecimal.create(1)}),
+        HiveDecimal.create(3));
   }
 
   @Test
@@ -676,29 +675,29 @@ public class TestVectorGroupByOperator {
         "min",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(1),
-                new Decimal128(2),
-                new Decimal128(3)}),
-       new Decimal128(1));
+                HiveDecimal.create(1),
+                HiveDecimal.create(2),
+                HiveDecimal.create(3)}),
+       HiveDecimal.create(1));
     testAggregateDecimal(
         "Decimal",
         "min",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(3),
-                new Decimal128(2),
-                new Decimal128(1)}),
-        new Decimal128(1));
+                HiveDecimal.create(3),
+                HiveDecimal.create(2),
+                HiveDecimal.create(1)}),
+        HiveDecimal.create(1));
 
     testAggregateDecimal(
         "Decimal",
         "min",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(2),
-                new Decimal128(1),
-                new Decimal128(3)}),
-        new Decimal128(1));
+                HiveDecimal.create(2),
+                HiveDecimal.create(1),
+                HiveDecimal.create(3)}),
+        HiveDecimal.create(1));
   }
 
   @Test
@@ -708,10 +707,10 @@ public class TestVectorGroupByOperator {
        "sum",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(1),
-                new Decimal128(2),
-                new Decimal128(3)}),
-       new Decimal128(1+2+3));
+                HiveDecimal.create(1),
+                HiveDecimal.create(2),
+                HiveDecimal.create(3)}),
+       HiveDecimal.create(1+2+3));
   }
 
   @Test
@@ -722,12 +721,12 @@ public class TestVectorGroupByOperator {
         "sum",
         4,
         Arrays.asList(new Object[]{
-                new Decimal128("1234.2401", scale),
-                new Decimal128("1868.52", scale),
-                new Decimal128(0L, (short) 0),
-                new Decimal128("456.84", scale),
-                new Decimal128("121.89", scale)}),
-       new Decimal128("3681.4901", scale));
+                HiveDecimal.create("1234.2401").setScale(scale),
+                HiveDecimal.create("1868.52").setScale(scale),
+                HiveDecimal.ZERO.setScale(scale),
+                HiveDecimal.create("456.84").setScale(scale),
+                HiveDecimal.create("121.89").setScale(scale)}),
+       HiveDecimal.create("3681.4901").setScale( scale));
   }
 
   @Test
@@ -737,9 +736,9 @@ public class TestVectorGroupByOperator {
         "avg",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(1),
-                new Decimal128(2),
-                new Decimal128(3)}),
+                HiveDecimal.create(1),
+                HiveDecimal.create(2),
+                HiveDecimal.create(3)}),
        HiveDecimal.create((1+2+3)/3));
   }
 
@@ -750,9 +749,9 @@ public class TestVectorGroupByOperator {
         "avg",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(-1),
-                new Decimal128(-2),
-                new Decimal128(-3)}),
+                HiveDecimal.create(-1),
+                HiveDecimal.create(-2),
+                HiveDecimal.create(-3)}),
         HiveDecimal.create((-1-2-3)/3));
   }
 
@@ -763,10 +762,10 @@ public class TestVectorGroupByOperator {
         "variance",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(13),
-                new Decimal128(5),
-                new Decimal128(7),
-                new Decimal128(19)}),
+                HiveDecimal.create(13),
+                HiveDecimal.create(5),
+                HiveDecimal.create(7),
+                HiveDecimal.create(19)}),
         (double) 30);
   }
 
@@ -777,10 +776,10 @@ public class TestVectorGroupByOperator {
         "var_samp",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(13),
-                new Decimal128(5),
-                new Decimal128(7),
-                new Decimal128(19)}),
+                HiveDecimal.create(13),
+                HiveDecimal.create(5),
+                HiveDecimal.create(7),
+                HiveDecimal.create(19)}),
         (double) 40);
   }
 
@@ -791,10 +790,10 @@ public class TestVectorGroupByOperator {
         "stddev_pop",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(13),
-                new Decimal128(5),
-                new Decimal128(7),
-                new Decimal128(19)}),
+                HiveDecimal.create(13),
+                HiveDecimal.create(5),
+                HiveDecimal.create(7),
+                HiveDecimal.create(19)}),
         (double) Math.sqrt(30));
   }
 
@@ -805,10 +804,10 @@ public class TestVectorGroupByOperator {
         "stddev_samp",
         2,
         Arrays.asList(new Object[]{
-                new Decimal128(13),
-                new Decimal128(5),
-                new Decimal128(7),
-                new Decimal128(19)}),
+                HiveDecimal.create(13),
+                HiveDecimal.create(5),
+                HiveDecimal.create(7),
+                HiveDecimal.create(19)}),
         (double) Math.sqrt(40));
   }
 
@@ -820,8 +819,8 @@ public class TestVectorGroupByOperator {
             2,
             new String[] {"decimal(38,0)", "bigint"},
             Arrays.asList(new Object[]{
-                    new Decimal128(1),null,
-                    new Decimal128(1), null}),
+                    HiveDecimal.create(1),null,
+                    HiveDecimal.create(1), null}),
             Arrays.asList(new Object[]{13L,null,7L, 19L})),
         buildHashMap(HiveDecimal.create(1), 20L, null, 19L));
   }
@@ -2095,12 +2094,12 @@ public class TestVectorGroupByOperator {
       } else if (arr[0] instanceof HiveDecimalWritable) {
         HiveDecimalWritable hdw = (HiveDecimalWritable) arr[0];
         HiveDecimal hd = hdw.getHiveDecimal();
-        Decimal128 d128 = (Decimal128)expected;
-        assertEquals (key, d128.toBigDecimal(), hd.bigDecimalValue());
+        HiveDecimal expectedDec = (HiveDecimal)expected;
+        assertEquals (key, expectedDec, hd);
       } else if (arr[0] instanceof HiveDecimal) {
           HiveDecimal hd = (HiveDecimal) arr[0];
-          Decimal128 d128 = (Decimal128)expected;
-          assertEquals (key, d128.toBigDecimal(), hd.bigDecimalValue());
+          HiveDecimal expectedDec = (HiveDecimal)expected;
+          assertEquals (key, expectedDec, hd);
       } else {
         Assert.fail("Unsupported result type: " + arr[0].getClass().getName());
       }

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestConstantVectorExpression.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestConstantVectorExpression.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestConstantVectorExpression.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestConstantVectorExpression.java Sat Nov  1 21:10:32 2014
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTru
 
 import java.util.Arrays;
 
-import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
@@ -43,7 +43,7 @@ public class TestConstantVectorExpressio
     ConstantVectorExpression doubleCve = new ConstantVectorExpression(1, 17.34);
     String str = "alpha";
     ConstantVectorExpression bytesCve = new ConstantVectorExpression(2, str.getBytes());
-    Decimal128 decVal = new Decimal128(25.8, (short) 1);
+    HiveDecimal decVal = HiveDecimal.create("25.8");
     ConstantVectorExpression decimalCve = new ConstantVectorExpression(3, decVal);
     ConstantVectorExpression nullCve = new ConstantVectorExpression(4, "string", true);
     
@@ -85,12 +85,12 @@ public class TestConstantVectorExpressio
     assertTrue(bcv.length[0] == alphaBytes.length);
     assertTrue(sameFirstKBytes(alphaBytes, bcv.vector[0], alphaBytes.length)); 
 
-    assertTrue(25.8 == dv.vector[0].doubleValue());
+    assertTrue(25.8 == dv.vector[0].getHiveDecimal().doubleValue());
     // Evaluation of the decimal Constant Vector Expression after the vector is
     // modified.    
-    ((DecimalColumnVector) (vrg.cols[3])).vector[0] = new Decimal128(39.7, (short) 1);
+    ((DecimalColumnVector) (vrg.cols[3])).vector[0].set(HiveDecimal.create("39.7"));
     decimalCve.evaluate(vrg);
-    assertTrue(25.8 == dv.vector[0].doubleValue());    
+    assertTrue(25.8 == dv.vector[0].getHiveDecimal().doubleValue());    
   }
   
   private boolean sameFirstKBytes(byte[] o1, byte[] o2, int k) {

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestDecimalUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestDecimalUtil.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestDecimalUtil.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestDecimalUtil.java Sat Nov  1 21:10:32 2014
@@ -19,7 +19,8 @@
 package org.apache.hadoop.hive.ql.exec.vector.expressions;
 
 import junit.framework.Assert;
-import org.apache.hadoop.hive.common.type.Decimal128;
+
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.junit.Test;
@@ -32,183 +33,198 @@ public class TestDecimalUtil {
   @Test
   public void testFloor() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 13);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
-    Decimal128 expected1 = new Decimal128(19, (short)0);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
+    HiveDecimal expected1 = HiveDecimal.create("19");
     DecimalUtil.floor(0, d1, dcv);
-    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(23.0, (short) 5);
-    Decimal128 expected2 = new Decimal128(23, (short)0);
+    HiveDecimal d2 = HiveDecimal.create("23.00000");
+    Assert.assertEquals(5, d2.scale());
+    HiveDecimal expected2 = HiveDecimal.create("23");
     DecimalUtil.floor(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d3 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected3 = new Decimal128(-26, (short)0);
+    HiveDecimal d3 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected3 = HiveDecimal.create("-26");
     DecimalUtil.floor(0, d3, dcv);
-    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d4 = new Decimal128(-17, (short) 5);
-    Decimal128 expected4 = new Decimal128(-17, (short)0);
+    HiveDecimal d4 = HiveDecimal.create("-17.00000");
+    Assert.assertEquals(5, d4.scale());
+    HiveDecimal expected4 = HiveDecimal.create("-17");
     DecimalUtil.floor(0, d4, dcv);
-    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d5 = new Decimal128(-0.3, (short) 5);
-    Decimal128 expected5 = new Decimal128(-1, (short)0);
+    HiveDecimal d5 = HiveDecimal.create("-0.30000");
+    Assert.assertEquals(5, d5.scale());
+    HiveDecimal expected5 = HiveDecimal.create("-1");
     DecimalUtil.floor(0, d5, dcv);
-    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d6 = new Decimal128(0.3, (short) 5);
-    Decimal128 expected6 = new Decimal128(0, (short)0);
+    HiveDecimal d6 = HiveDecimal.create("0.30000");
+    Assert.assertEquals(5, d6.scale());
+    HiveDecimal expected6 = HiveDecimal.create("0");
     DecimalUtil.floor(0, d6, dcv);
-    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testCeiling() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 13);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
-    Decimal128 expected1 = new Decimal128(20, (short)0);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
+    HiveDecimal expected1 = HiveDecimal.create("20");
     DecimalUtil.ceiling(0, d1, dcv);
-    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(23.0, (short) 5);
-    Decimal128 expected2 = new Decimal128(23, (short)0);
+    HiveDecimal d2 = HiveDecimal.create("23.00000");
+    Assert.assertEquals(5, d2.scale());
+    HiveDecimal expected2 = HiveDecimal.create("23");
     DecimalUtil.ceiling(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d3 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected3 = new Decimal128(-25, (short)0);
+    HiveDecimal d3 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected3 = HiveDecimal.create("-25");
     DecimalUtil.ceiling(0, d3, dcv);
-    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d4 = new Decimal128(-17, (short) 5);
-    Decimal128 expected4 = new Decimal128(-17, (short)0);
+    HiveDecimal d4 = HiveDecimal.create("-17.00000");
+    Assert.assertEquals(5, d4.scale());
+    HiveDecimal expected4 = HiveDecimal.create("-17");
     DecimalUtil.ceiling(0, d4, dcv);
-    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d5 = new Decimal128(-0.3, (short) 5);
-    Decimal128 expected5 = new Decimal128(0, (short)0);
+    HiveDecimal d5 = HiveDecimal.create("-0.30000");
+    Assert.assertEquals(5, d5.scale());
+    HiveDecimal expected5 = HiveDecimal.create("0");
     DecimalUtil.ceiling(0, d5, dcv);
-    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d6 = new Decimal128(0.3, (short) 5);
-    Decimal128 expected6 = new Decimal128(1, (short)0);
+    HiveDecimal d6 = HiveDecimal.create("0.30000");
+    Assert.assertEquals(5, d6.scale());
+    HiveDecimal expected6 = HiveDecimal.create("1");
     DecimalUtil.ceiling(0, d6, dcv);
-    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testAbs() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 13);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
     DecimalUtil.abs(0, d1, dcv);
-    Assert.assertEquals(0, d1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, d1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected2 = new Decimal128(25.34567, (short)5);
+    HiveDecimal d2 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected2 = HiveDecimal.create("25.34567");
     DecimalUtil.abs(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testRound() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 0);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
-    Decimal128 expected1 = new Decimal128(20, (short)0);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
+    HiveDecimal expected1 = HiveDecimal.create("20");
     DecimalUtil.round(0, d1, dcv);
-    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(23.0, (short) 5);
-    Decimal128 expected2 = new Decimal128(23, (short)0);
+    HiveDecimal d2 = HiveDecimal.create("23.00000");
+    Assert.assertEquals(5, d2.scale());
+    HiveDecimal expected2 = HiveDecimal.create("23");
     DecimalUtil.round(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d3 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected3 = new Decimal128(-25, (short)0);
+    HiveDecimal d3 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected3 = HiveDecimal.create("-25");
     DecimalUtil.round(0, d3, dcv);
-    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d4 = new Decimal128(-17, (short) 5);
-    Decimal128 expected4 = new Decimal128(-17, (short)0);
+    HiveDecimal d4 = HiveDecimal.create("-17.00000");
+    Assert.assertEquals(5, d4.scale());
+    HiveDecimal expected4 = HiveDecimal.create("-17");
     DecimalUtil.round(0, d4, dcv);
-    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d5 = new Decimal128(19.36778, (short) 5);
-    Decimal128 expected5 = new Decimal128(19, (short)0);
+    HiveDecimal d5 = HiveDecimal.create("19.36778");
+    HiveDecimal expected5 = HiveDecimal.create("19");
     DecimalUtil.round(0, d5, dcv);
-    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d6 = new Decimal128(-25.54567, (short) 5);
-    Decimal128 expected6 = new Decimal128(-26, (short)0);
+    HiveDecimal d6 = HiveDecimal.create("-25.54567");
+    HiveDecimal expected6 = HiveDecimal.create("-26");
     DecimalUtil.round(0, d6, dcv);
-    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testRoundWithDigits() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 3);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
-    Decimal128 expected1 = new Decimal128(19.568, (short)3);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
+    HiveDecimal expected1 = HiveDecimal.create("19.568");
     DecimalUtil.round(0, d1, dcv);
-    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(23.567, (short) 5);
-    Decimal128 expected2 = new Decimal128(23.567, (short)3);
+    HiveDecimal d2 = HiveDecimal.create("23.56700");
+    Assert.assertEquals(5, d2.scale());
+    HiveDecimal expected2 = HiveDecimal.create("23.567");
     DecimalUtil.round(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d3 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected3 = new Decimal128(-25.346, (short)3);
+    HiveDecimal d3 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected3 = HiveDecimal.create("-25.346");
     DecimalUtil.round(0, d3, dcv);
-    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d4 = new Decimal128(-17.234, (short) 5);
-    Decimal128 expected4 = new Decimal128(-17.234, (short)3);
+    HiveDecimal d4 = HiveDecimal.create("-17.23400");
+    Assert.assertEquals(5, d4.scale());
+    HiveDecimal expected4 = HiveDecimal.create("-17.234");
     DecimalUtil.round(0, d4, dcv);
-    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected4.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d5 = new Decimal128(19.36748, (short) 5);
-    Decimal128 expected5 = new Decimal128(19.367, (short)3);
+    HiveDecimal d5 = HiveDecimal.create("19.36748");
+    HiveDecimal expected5 = HiveDecimal.create("19.367");
     DecimalUtil.round(0, d5, dcv);
-    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected5.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d6 = new Decimal128(-25.54537, (short) 5);
-    Decimal128 expected6 = new Decimal128(-25.545, (short)3);
+    HiveDecimal d6 = HiveDecimal.create("-25.54537");
+    HiveDecimal expected6 = HiveDecimal.create("-25.545");
     DecimalUtil.round(0, d6, dcv);
-    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected6.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testNegate() {
     DecimalColumnVector dcv = new DecimalColumnVector(4 ,20, 13);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
-    Decimal128 expected1 = new Decimal128(-19.56778, (short)5);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
+    HiveDecimal expected1 = HiveDecimal.create("-19.56778");
     DecimalUtil.negate(0, d1, dcv);
-    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected1.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d2 = new Decimal128(-25.34567, (short) 5);
-    Decimal128 expected2 = new Decimal128(25.34567, (short)5);
+    HiveDecimal d2 = HiveDecimal.create("-25.34567");
+    HiveDecimal expected2 = HiveDecimal.create("25.34567");
     DecimalUtil.negate(0, d2, dcv);
-    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected2.compareTo(dcv.vector[0].getHiveDecimal()));
 
-    Decimal128 d3 = new Decimal128(0, (short) 5);
-    Decimal128 expected3 = new Decimal128(0, (short)0);
+    HiveDecimal d3 = HiveDecimal.create("0.00000");
+    Assert.assertEquals(5, d3.scale());
+    HiveDecimal expected3 = HiveDecimal.create("0");
     DecimalUtil.negate(0, d3, dcv);
-    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0]));
+    Assert.assertEquals(0, expected3.compareTo(dcv.vector[0].getHiveDecimal()));
   }
 
   @Test
   public void testSign() {
     LongColumnVector lcv = new LongColumnVector(4);
-    Decimal128 d1 = new Decimal128(19.56778, (short) 5);
+    HiveDecimal d1 = HiveDecimal.create("19.56778");
     DecimalUtil.sign(0, d1, lcv);
     Assert.assertEquals(1, lcv.vector[0]);
 
-    Decimal128 d2 = new Decimal128(-25.34567, (short) 5);
+    HiveDecimal d2 = HiveDecimal.create("-25.34567");
     DecimalUtil.sign(0, d2, lcv);
     Assert.assertEquals(-1, lcv.vector[0]);
 
-    Decimal128 d3 = new Decimal128(0, (short) 5);
+    HiveDecimal d3 = HiveDecimal.create("0.00000");
+    Assert.assertEquals(5, d3.scale());
+    d3.setScale(5);
     DecimalUtil.sign(0, d3, lcv);
     Assert.assertEquals(0, lcv.vector[0]);
   }

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorArithmeticExpressions.java Sat Nov  1 21:10:32 2014
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertTrue;
 import junit.framework.Assert;
 
-import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
@@ -315,9 +315,9 @@ public class TestVectorArithmeticExpress
 
     // test without nulls
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-2.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1.00")));
 
     // test nulls propagation
     b = getVectorizedRowBatch3DecimalCols();
@@ -330,18 +330,18 @@ public class TestVectorArithmeticExpress
 
     // Verify null output data entry is not 0, but rather the value specified by design,
     // which is the minimum non-0 value, 0.01 in this case.
-    assertTrue(r.vector[0].equals(new Decimal128("0.01", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.01")));
 
     // test that overflow produces NULL
     b = getVectorizedRowBatch3DecimalCols();
     c0 = (DecimalColumnVector) b.cols[0];
-    c0.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    c0.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     r = (DecimalColumnVector) b.cols[2];
     expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
     assertTrue(!r.noNulls && r.isNull[0]);
 
     // verify proper null output data value
-    assertTrue(r.vector[0].equals(new Decimal128("0.01", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.01")));
 
     // test left input repeating
     b = getVectorizedRowBatch3DecimalCols();
@@ -349,25 +349,25 @@ public class TestVectorArithmeticExpress
     c0.isRepeating = true;
     r = (DecimalColumnVector) b.cols[2];
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("2.20", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("2.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("2.20")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("2.20")));
 
     // test both inputs repeating
     DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
     c1.isRepeating = true;
     expr.evaluate(b);
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
 
     // test right input repeating
     b = getVectorizedRowBatch3DecimalCols();
     c1 = (DecimalColumnVector) b.cols[1];
     c1.isRepeating = true;
-    c1.vector[0].update("2", (short) 2);
+    c1.vector[0].set(HiveDecimal.create("2.00"));
     r = (DecimalColumnVector) b.cols[2];
     expr.evaluate(b);
-    assertTrue(r.vector[2].equals(new Decimal128("2", (short) 2)));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("2.00")));
   }
 
   // Spot check decimal column-column subtract
@@ -379,14 +379,14 @@ public class TestVectorArithmeticExpress
 
     // test without nulls
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("0.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-4.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("-1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-4.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("-1.00")));
 
     // test that underflow produces NULL
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
-    c0.vector[0].update("-9999999999999999.99", (short) 2); // set to min possible value
+    c0.vector[0].set(HiveDecimal.create("-9999999999999999.99")); // set to min possible value
     r = (DecimalColumnVector) b.cols[2];
     expr.evaluate(b); // will cause underflow for result at position 0, must yield NULL
     assertTrue(!r.noNulls && r.isNull[0]);
@@ -401,16 +401,16 @@ public class TestVectorArithmeticExpress
 
     // test without nulls
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("1.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-3.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-3.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0.00")));
 
     // test that underflow produces NULL
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector c0 = (DecimalColumnVector) b.cols[0];
-    c0.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    c0.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     DecimalColumnVector c1 = (DecimalColumnVector) b.cols[1];
-    c1.vector[0].update("2", (short) 2);
+    c1.vector[0].set(HiveDecimal.create("2.00"));
     r = (DecimalColumnVector) b.cols[2];
     expr.evaluate(b); // will cause overflow for result at position 0, must yield NULL
     assertTrue(!r.noNulls && r.isNull[0]);
@@ -422,15 +422,15 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalColAddDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(1);
+    HiveDecimal d = HiveDecimal.create(1);
     VectorExpression expr = new DecimalColAddDecimalScalar(0, d, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-2.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1")));
 
     // test null propagation
     b = getVectorizedRowBatch3DecimalCols();
@@ -449,7 +449,7 @@ public class TestVectorArithmeticExpress
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
 
     // test repeating case for null value
     b = getVectorizedRowBatch3DecimalCols();
@@ -466,7 +466,7 @@ public class TestVectorArithmeticExpress
     // test that overflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    in.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -480,16 +480,16 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalColDivideDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128("2.00", (short) 2);
+    HiveDecimal d = HiveDecimal.create("2.00");
     VectorExpression expr = new DecimalColDivideDecimalScalar(0, d, 2);
 
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("0.60", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-1.65", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.6")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.65")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // test null propagation
     b = getVectorizedRowBatch3DecimalCols();
@@ -508,7 +508,7 @@ public class TestVectorArithmeticExpress
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("0.60", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.6")));
 
     // test repeating case for null value
     b = getVectorizedRowBatch3DecimalCols();
@@ -525,7 +525,7 @@ public class TestVectorArithmeticExpress
     // test that zero-divide produces null for all output values
     b = getVectorizedRowBatch3DecimalCols();
     in = (DecimalColumnVector) b.cols[0];
-    expr = new DecimalColDivideDecimalScalar(0, new Decimal128("0", (short) 2), 2);
+    expr = new DecimalColDivideDecimalScalar(0, HiveDecimal.create("0"), 2);
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -539,14 +539,14 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalScalarDivideDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128("3.96", (short) 2);  // 1.20 * 3.30
+    HiveDecimal d = HiveDecimal.create("3.96");  // 1.20 * 3.30
     VectorExpression expr = new DecimalScalarDivideDecimalColumn(d, 0, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("3.30", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-1.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("3.3")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.2")));
     assertFalse(r.noNulls); // entry 2 is null due to zero-divide
     assertTrue(r.isNull[2]);
 
@@ -567,7 +567,7 @@ public class TestVectorArithmeticExpress
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("3.30", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("3.3")));
 
     // test repeating case for null value
     b = getVectorizedRowBatch3DecimalCols();
@@ -586,30 +586,32 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalColModuloDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128("2.00", (short) 2);
+    HiveDecimal d = HiveDecimal.create("2.00");
     VectorExpression expr = new DecimalColModuloDecimalScalar(0, d, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("1.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-1.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // try again with some different data values and divisor
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("15.40", (short) 2);
-    in.vector[1].update("-17.20", (short) 2);
-    in.vector[2].update("70.00", (short) 2);
-    d.update("4.75", (short) 2);
+    in.vector[0].set(HiveDecimal.create("15.40"));
+    in.vector[1].set(HiveDecimal.create("-17.20"));
+    in.vector[2].set(HiveDecimal.create("70.00"));
+    d = HiveDecimal.create("4.75");
+    expr = new DecimalColModuloDecimalScalar(0, d, 2);
 
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("1.15", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-2.95", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("3.50", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.15")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.95")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("3.50")));
 
     // try a zero-divide to show a repeating NULL is produced
-    d.update("0", (short) 2);
+    d = HiveDecimal.create("0.00");
+    expr = new DecimalColModuloDecimalScalar(0, d, 2);
     expr.evaluate(b);
     assertFalse(r.noNulls);
     assertTrue(r.isNull[0]);
@@ -620,27 +622,28 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalScalarModuloDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128("2.00", (short) 2);
+    HiveDecimal d = HiveDecimal.create("2.00");
     VectorExpression expr = new DecimalScalarModuloDecimalColumn(d, 0, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("0.80", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("2.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.80")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("2.00")));
     assertFalse(r.noNulls); // entry 2 will be null due to zero-divide
     assertTrue(r.isNull[2]);
 
     // try again with some different data values
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("0.50", (short) 2);
-    in.vector[1].update("0.80", (short) 2);
-    in.vector[2].update("0.70", (short) 2);
+    expr = new DecimalScalarModuloDecimalColumn(d, 0, 2);
+    in.vector[0].set(HiveDecimal.create("0.50"));
+    in.vector[1].set(HiveDecimal.create("0.80"));
+    in.vector[2].set(HiveDecimal.create("0.70"));
 
     expr.evaluate(b);
-    assertTrue(r.vector[0].equals(new Decimal128("0.00", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("0.40", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0.60", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.00")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("0.40")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0.60")));
   }
 
   @Test
@@ -648,16 +651,16 @@ public class TestVectorArithmeticExpress
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in1 = (DecimalColumnVector) b.cols[1];
     for (int i = 0; i < 3; i++) {
-      in1.vector[i] = new Decimal128("0.50", (short) 2);
+      in1.vector[i].set(HiveDecimal.create("0.50"));
     }
     VectorExpression expr = new DecimalColDivideDecimalColumn(0, 1, 2);
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
 
     // all divides are by 0.50 so the result column is 2 times col 0.
-    assertTrue(r.vector[0].equals(new Decimal128("2.40", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-6.60", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.4")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-6.6")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // test null on left
     b.cols[0].noNulls = false;
@@ -692,14 +695,14 @@ public class TestVectorArithmeticExpress
     b.cols[0].isRepeating = true;
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[2].equals(new Decimal128("1.20", (short) 2)));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1.2")));
 
     // test repeating on right
     b = getVectorizedRowBatch3DecimalCols();
     b.cols[1].isRepeating = true;
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // test both repeating
     b = getVectorizedRowBatch3DecimalCols();
@@ -708,11 +711,11 @@ public class TestVectorArithmeticExpress
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("1.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.2")));
 
     // test zero-divide to show it results in NULL
     b = getVectorizedRowBatch3DecimalCols();
-    ((DecimalColumnVector) b.cols[1]).vector[0].update(0);
+    ((DecimalColumnVector) b.cols[1]).vector[0].set(HiveDecimal.create("0"));
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -725,15 +728,15 @@ public class TestVectorArithmeticExpress
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in1 = (DecimalColumnVector) b.cols[1];
     for (int i = 0; i < 3; i++) {
-      in1.vector[i] = new Decimal128("0.50", (short) 2);
+      in1.vector[i].set(HiveDecimal.create("0.50"));
     }
     VectorExpression expr = new DecimalColModuloDecimalColumn(0, 1, 2);
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
 
-    assertTrue(r.vector[0].equals(new Decimal128("0.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-0.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-0.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
   }
 
   /* Spot check correctness of decimal column subtract decimal scalar. The case for
@@ -742,20 +745,20 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalColSubtractDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(1);
+    HiveDecimal d = HiveDecimal.create(1);
     VectorExpression expr = new DecimalColSubtractDecimalScalar(0, d, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("0.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-4.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("-1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-4.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("-1")));
 
     // test that underflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("-9999999999999999.99", (short) 2); // set to min possible value
+    in.vector[0].set(HiveDecimal.create("-9999999999999999.99")); // set to min possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -768,20 +771,20 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalColMultiplyDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(2);
+    HiveDecimal d = HiveDecimal.create(2);
     VectorExpression expr = new DecimalColMultiplyDecimalScalar(0, d, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("2.40", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-6.60", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.40")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-6.60")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // test that overflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    in.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -794,15 +797,15 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalScalarAddDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(1);
+    HiveDecimal d = HiveDecimal.create(1);
     VectorExpression expr = new DecimalScalarAddDecimalColumn(d, 0, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-2.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1")));
 
     // test null propagation
     b = getVectorizedRowBatch3DecimalCols();
@@ -821,7 +824,7 @@ public class TestVectorArithmeticExpress
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertTrue(r.isRepeating);
-    assertTrue(r.vector[0].equals(new Decimal128("2.20", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.20")));
 
     // test repeating case for null value
     b = getVectorizedRowBatch3DecimalCols();
@@ -838,7 +841,7 @@ public class TestVectorArithmeticExpress
     // test that overflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    in.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -851,20 +854,20 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalScalarSubtractDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(1);
+    HiveDecimal d = HiveDecimal.create(1);
     VectorExpression expr = new DecimalScalarSubtractDecimalColumn(d, 0, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("-0.20", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("4.30", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("1.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("-0.20")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("4.30")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("1")));
 
     // test that overflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("-9999999999999999.99", (short) 2); // set to min possible value
+    in.vector[0].set(HiveDecimal.create("-9999999999999999.99")); // set to min possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -878,20 +881,20 @@ public class TestVectorArithmeticExpress
   @Test
   public void testDecimalScalarMultiplyDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch3DecimalCols();
-    Decimal128 d = new Decimal128(2);
+    HiveDecimal d = HiveDecimal.create(2);
     VectorExpression expr = new DecimalScalarMultiplyDecimalColumn(d, 0, 2);
 
     // test without nulls
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[2];
-    assertTrue(r.vector[0].equals(new Decimal128("2.40", (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-6.60", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("0", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("2.40")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-6.60")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("0")));
 
     // test that overflow produces null
     b = getVectorizedRowBatch3DecimalCols();
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[0].update("9999999999999999.99", (short) 2); // set to max possible value
+    in.vector[0].set(HiveDecimal.create("9999999999999999.99")); // set to max possible value
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[2];
     assertFalse(r.noNulls);
@@ -905,13 +908,13 @@ public class TestVectorArithmeticExpress
     b.cols[0] = v0 = new DecimalColumnVector(18, 2);
     b.cols[1] = v1 = new DecimalColumnVector(18, 2);
     b.cols[2] = new DecimalColumnVector(18, 2);
-    v0.vector[0].update("1.20", (short) 2);
-    v0.vector[1].update("-3.30", (short) 2);
-    v0.vector[2].update("0", (short) 2);
-
-    v1.vector[0].update("1.00", (short) 2);
-    v1.vector[1].update("1.00", (short) 2);
-    v1.vector[2].update("1.00", (short) 2);
+    v0.vector[0].set(HiveDecimal.create("1.20"));
+    v0.vector[1].set(HiveDecimal.create("-3.30"));
+    v0.vector[2].set(HiveDecimal.create("0"));
+
+    v1.vector[0].set(HiveDecimal.create("1.00"));
+    v1.vector[1].set(HiveDecimal.create("1.00"));
+    v1.vector[2].set(HiveDecimal.create("1.00"));
 
     b.size = 3;
 

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorExpressionWriters.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorExpressionWriters.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorExpressionWriters.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorExpressionWriters.java Sat Nov  1 21:10:32 2014
@@ -84,8 +84,8 @@ public class TestVectorExpressionWriters
     return null;
   }
 
-  private Writable getWritableValue(TypeInfo ti, Decimal128 value) {
-    return new HiveDecimalWritable(HiveDecimal.create(value.toBigDecimal()));
+  private Writable getWritableValue(TypeInfo ti, HiveDecimal value) {
+    return new HiveDecimalWritable(value);
   }
 
   private Writable getWritableValue(TypeInfo ti, byte[] value) {
@@ -163,7 +163,7 @@ public class TestVectorExpressionWriters
     for (int i = 0; i < vectorSize; i++) {
       Writable w = (Writable) vew.writeValue(dcv, i);
       if (w != null) {
-        Writable expected = getWritableValue(type, dcv.vector[i]);
+        Writable expected = getWritableValue(type, dcv.vector[i].getHiveDecimal());
         Assert.assertEquals(expected, w);
       } else {
         Assert.assertTrue(dcv.isNull[i]);
@@ -182,7 +182,7 @@ public class TestVectorExpressionWriters
       values[i] = null;  // setValue() should be able to handle null input
       values[i] = vew.setValue(values[i], dcv, i);
       if (values[i] != null) {
-        Writable expected = getWritableValue(type, dcv.vector[i]);
+        Writable expected = getWritableValue(type, dcv.vector[i].getHiveDecimal());
         Assert.assertEquals(expected, values[i]);
       } else {
         Assert.assertTrue(dcv.isNull[i]);

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorFilterExpressions.java Sat Nov  1 21:10:32 2014
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTru
 
 import java.sql.Timestamp;
 
-import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
@@ -830,8 +830,7 @@ public class TestVectorFilterExpressions
   @Test
   public void testFilterDecimalColEqualDecimalScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch1DecimalCol();
-    Decimal128 scalar = new Decimal128();
-    scalar.update("-3.30", (short) 2);
+    HiveDecimal scalar = HiveDecimal.create("-3.30");
     VectorExpression expr = new FilterDecimalColEqualDecimalScalar(0, scalar);
     expr.evaluate(b);
 
@@ -876,8 +875,7 @@ public class TestVectorFilterExpressions
   @Test
   public void testFilterDecimalScalarEqualDecimalColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch1DecimalCol();
-    Decimal128 scalar = new Decimal128();
-    scalar.update("-3.30", (short) 2);
+    HiveDecimal scalar = HiveDecimal.create("-3.30");
     VectorExpression expr = new FilterDecimalScalarEqualDecimalColumn(scalar, 0);
     expr.evaluate(b);
 
@@ -982,8 +980,7 @@ public class TestVectorFilterExpressions
   @Test
   public void testFilterDecimalColLessScalar() {
     VectorizedRowBatch b = getVectorizedRowBatch1DecimalCol();
-    Decimal128 scalar = new Decimal128();
-    scalar.update("0", (short) 2);
+    HiveDecimal scalar = HiveDecimal.create("0");
     VectorExpression expr = new FilterDecimalColLessDecimalScalar(0, scalar);
     expr.evaluate(b);
 
@@ -999,8 +996,7 @@ public class TestVectorFilterExpressions
   @Test
   public void testFilterDecimalScalarGreaterThanColumn() {
     VectorizedRowBatch b = getVectorizedRowBatch1DecimalCol();
-    Decimal128 scalar = new Decimal128();
-    scalar.update("0", (short) 2);
+    HiveDecimal scalar = HiveDecimal.create("0");
     VectorExpression expr = new FilterDecimalScalarGreaterDecimalColumn(scalar, 0);
     expr.evaluate(b);
 
@@ -1030,9 +1026,9 @@ public class TestVectorFilterExpressions
     VectorizedRowBatch b = new VectorizedRowBatch(1);
     DecimalColumnVector v0;
     b.cols[0] = v0 = new DecimalColumnVector(18, 2);
-    v0.vector[0].update("1.20", (short) 2);
-    v0.vector[1].update("-3.30", (short) 2);
-    v0.vector[2].update("0", (short) 2);
+    v0.vector[0].set(HiveDecimal.create("1.20"));
+    v0.vector[1].set(HiveDecimal.create("-3.30"));
+    v0.vector[2].set(HiveDecimal.create("0"));
 
     b.size = 3;
     return b;
@@ -1042,14 +1038,14 @@ public class TestVectorFilterExpressions
     VectorizedRowBatch b = new VectorizedRowBatch(2);
     DecimalColumnVector v0, v1;
     b.cols[0] = v0 = new DecimalColumnVector(18, 2);
-    v0.vector[0].update("1.20", (short) 2);
-    v0.vector[1].update("-3.30", (short) 2);
-    v0.vector[2].update("0", (short) 2);
+    v0.vector[0].set(HiveDecimal.create("1.20"));
+    v0.vector[1].set(HiveDecimal.create("-3.30"));
+    v0.vector[2].set(HiveDecimal.create("0"));
 
     b.cols[1] = v1 = new DecimalColumnVector(18, 2);
-    v1.vector[0].update("-1", (short) 2);
-    v1.vector[1].update("-3.30", (short) 2);
-    v1.vector[2].update("10", (short) 2);
+    v1.vector[0].set(HiveDecimal.create("-1.00"));
+    v1.vector[1].set(HiveDecimal.create("-3.30"));
+    v1.vector[2].set(HiveDecimal.create("10.00"));
 
     b.size = 3;
     return b;

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java Sat Nov  1 21:10:32 2014
@@ -28,6 +28,7 @@ import java.util.Arrays;
 import junit.framework.Assert;
 
 import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
@@ -231,7 +232,7 @@ public class TestVectorTypeCasts {
     VectorizedRowBatch b = getBatchDecimalLong();
     VectorExpression expr = new CastDecimalToBoolean(0, 1);
     DecimalColumnVector in = (DecimalColumnVector) b.cols[0];
-    in.vector[1].update(0);
+    in.vector[1].set(HiveDecimal.create(0));
     expr.evaluate(b);
     LongColumnVector r = (LongColumnVector) b.cols[1];
     assertEquals(1, r.vector[0]);
@@ -248,9 +249,9 @@ public class TestVectorTypeCasts {
 
     b.size = 3;
 
-    dv.vector[0].update("1.1", scale);
-    dv.vector[1].update("-2.2", scale);
-    dv.vector[2].update("9999999999999999.00", scale);
+    dv.vector[0].set(HiveDecimal.create("1.1").setScale(scale));
+    dv.vector[1].set(HiveDecimal.create("-2.2").setScale(scale));
+    dv.vector[2].set(HiveDecimal.create("9999999999999999.00").setScale(scale));
 
     return b;
   }
@@ -308,9 +309,9 @@ public class TestVectorTypeCasts {
 
     b.size = 3;
 
-    dv.vector[0].update("1.1", scale);
-    dv.vector[1].update("-2.2", scale);
-    dv.vector[2].update("9999999999999999.00", scale);
+    dv.vector[0].set(HiveDecimal.create("1.1").setScale(scale));
+    dv.vector[1].set(HiveDecimal.create("-2.2").setScale(scale));
+    dv.vector[2].set(HiveDecimal.create("9999999999999999.00").setScale(scale));
 
     return b;
   }
@@ -322,12 +323,13 @@ public class TestVectorTypeCasts {
     expr.evaluate(b);
     BytesColumnVector r = (BytesColumnVector) b.cols[1];
 
-    byte[] v = toBytes("1.1");
+    byte[] v = toBytes("1.10");
+    assertTrue(((Integer) v.length).toString() + " " + r.length[0], v.length == r.length[0]);
     Assert.assertEquals(0,
         StringExpr.compare(v, 0, v.length,
             r.vector[0], r.start[0], r.length[0]));
 
-    v = toBytes("-2.2");
+    v = toBytes("-2.20");
     Assert.assertEquals(0,
         StringExpr.compare(v, 0, v.length,
             r.vector[1], r.start[1], r.length[1]));
@@ -347,9 +349,9 @@ public class TestVectorTypeCasts {
 
     b.size = 3;
 
-    dv.vector[0].update("1.1", scale);
-    dv.vector[1].update("-2.2", scale);
-    dv.vector[2].update("9999999999999999.00", scale);
+    dv.vector[0].set(HiveDecimal.create("1.1").setScale(scale));
+    dv.vector[1].set(HiveDecimal.create("-2.2").setScale(scale));
+    dv.vector[2].set(HiveDecimal.create("9999999999999999.00").setScale(scale));
 
     return b;
   }
@@ -374,9 +376,9 @@ public class TestVectorTypeCasts {
 
     b.size = 3;
 
-    dv.vector[0].update("1.111111111", scale);
-    dv.vector[1].update("-2.222222222", scale);
-    dv.vector[2].update("31536000.999999999", scale);
+    dv.vector[0].set(HiveDecimal.create("1.111111111").setScale(scale));
+    dv.vector[1].set(HiveDecimal.create("-2.222222222").setScale(scale));
+    dv.vector[2].set(HiveDecimal.create("31536000.999999999").setScale(scale));
 
     return b;
   }
@@ -387,9 +389,9 @@ public class TestVectorTypeCasts {
     VectorExpression expr = new CastLongToDecimal(0, 1);
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
-    assertTrue(r.vector[0].equals(new Decimal128(0, (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128(-1, (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128(99999999999999L, (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("99999999999999")));
   }
 
   private VectorizedRowBatch getBatchLongDecimal() {
@@ -410,9 +412,9 @@ public class TestVectorTypeCasts {
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
 
-    assertTrue(r.vector[0].equals(new Decimal128(0, r.scale)));
-    assertTrue(r.vector[1].equals(new Decimal128(-1, r.scale)));
-    assertTrue(r.vector[2].equals(new Decimal128("99999999999999.0", r.scale)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.0")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.0")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("99999999999999")));
   }
 
   private VectorizedRowBatch getBatchDoubleDecimal() {
@@ -437,9 +439,9 @@ public class TestVectorTypeCasts {
     VectorExpression expr = new CastStringToDecimal(0, 1);
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
-    assertTrue(r.vector[0].equals(new Decimal128("1.10", r.scale)));
-    assertTrue(r.vector[1].equals(new Decimal128("-2.20", r.scale)));
-    assertTrue(r.vector[2].equals(new Decimal128("99999999999999.0", r.scale)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("1.10")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-2.20")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("99999999999999.0")));
   }
 
   private VectorizedRowBatch getBatchStringDecimal() {
@@ -472,9 +474,9 @@ public class TestVectorTypeCasts {
     inL.vector[1] = -1990000000L;
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
-    assertTrue(r.vector[0].equals(new Decimal128(0, (short) 2)));
-    assertTrue(r.vector[1].equals(new Decimal128("-1.99", (short) 2)));
-    assertTrue(r.vector[2].equals(new Decimal128("100000.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("0.00")));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-1.99")));
+    assertTrue(r.vector[2].getHiveDecimal().equals(HiveDecimal.create("100000.00")));
 
     // Try again with a value that won't fit in 5 digits, to make
     // sure that NULL is produced.
@@ -503,6 +505,7 @@ public class TestVectorTypeCasts {
     return b;
   }
 
+  /*
   @Test
   public void testCastDecimalToDecimal() {
 
@@ -511,7 +514,7 @@ public class TestVectorTypeCasts {
     VectorExpression expr = new CastDecimalToDecimal(0, 1);
     expr.evaluate(b);
     DecimalColumnVector r = (DecimalColumnVector) b.cols[1];
-    assertTrue(r.vector[0].equals(new Decimal128("10.00", (short) 2)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("10.00", (short) 2)));
     assertFalse(r.noNulls);
     assertTrue(r.isNull[1]);
 
@@ -520,10 +523,11 @@ public class TestVectorTypeCasts {
     expr = new CastDecimalToDecimal(1, 0);
     expr.evaluate(b);
     r = (DecimalColumnVector) b.cols[0];
-    assertTrue(r.vector[0].equals(new Decimal128("100.01", (short) 4)));
-    assertTrue(r.vector[1].equals(new Decimal128("-200.02", (short) 4)));
+    assertTrue(r.vector[0].getHiveDecimal().equals(HiveDecimal.create("100.01", (short) 4)));
+    assertTrue(r.vector[1].getHiveDecimal().equals(HiveDecimal.create("-200.02", (short) 4)));
     assertTrue(r.noNulls);
   }
+  */
 
   private VectorizedRowBatch getBatchDecimalDecimal() {
     VectorizedRowBatch b = new VectorizedRowBatch(2);
@@ -532,11 +536,11 @@ public class TestVectorTypeCasts {
     b.cols[0] = v0 = new DecimalColumnVector(18, 4);
     b.cols[1] = v1 = new DecimalColumnVector(5, 2);
 
-    v0.vector[0].update(new Decimal128("10.0001", (short) 4));
-    v0.vector[1].update(new Decimal128("-9999999.9999", (short) 4));
+    v0.vector[0].set(HiveDecimal.create("10.0001"));
+    v0.vector[1].set(HiveDecimal.create("-9999999.9999"));
 
-    v1.vector[0].update(new Decimal128("100.01", (short) 2));
-    v1.vector[1].update(new Decimal128("-200.02", (short) 2));
+    v1.vector[0].set(HiveDecimal.create("100.01"));
+    v1.vector[1].set(HiveDecimal.create("-200.02"));
 
     b.size = 2;
     return b;

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/FakeVectorRowBatchFromObjectIterables.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/FakeVectorRowBatchFromObjectIterables.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/FakeVectorRowBatchFromObjectIterables.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/FakeVectorRowBatchFromObjectIterables.java Sat Nov  1 21:10:32 2014
@@ -26,7 +26,7 @@ import java.util.regex.MatchResult;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
@@ -168,7 +168,7 @@ public class FakeVectorRowBatchFromObjec
                         int row,
                         Object value) {
                     DecimalColumnVector dcv = (DecimalColumnVector) columnVector;
-                    dcv.vector[row] = (Decimal128)value;
+                    dcv.set(row, (HiveDecimal) value);
                 }
             };
       } else {

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/VectorizedRowGroupGenUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/VectorizedRowGroupGenUtil.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/VectorizedRowGroupGenUtil.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/util/VectorizedRowGroupGenUtil.java Sat Nov  1 21:10:32 2014
@@ -21,10 +21,12 @@ package org.apache.hadoop.hive.ql.exec.v
 import java.util.Random;
 
 import org.apache.hadoop.hive.common.type.Decimal128;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
 import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
 
 public class VectorizedRowGroupGenUtil {
@@ -114,10 +116,10 @@ public class VectorizedRowGroupGenUtil {
     dcv.noNulls = !nulls;
     dcv.isRepeating = repeating;
 
-    Decimal128 repeatingValue = new Decimal128();
+    HiveDecimalWritable repeatingValue = new HiveDecimalWritable();
     do{
-      repeatingValue.update(rand.nextDouble(), (short)typeInfo.scale());
-    }while(repeatingValue.doubleValue() == 0);
+      repeatingValue.set(HiveDecimal.create(((Double) rand.nextDouble()).toString()).setScale((short)typeInfo.scale()));
+    }while(repeatingValue.getHiveDecimal().doubleValue() == 0);
 
     int nullFrequency = generateNullFrequency(rand);
 
@@ -129,12 +131,12 @@ public class VectorizedRowGroupGenUtil {
       }else {
         dcv.isNull[i] = false;
         if (repeating) {
-          dcv.vector[i].update(repeatingValue);
+          dcv.vector[i].set(repeatingValue);
         } else {
-          dcv.vector[i].update(rand.nextDouble(), (short) typeInfo.scale());
+          dcv.vector[i].set(HiveDecimal.create(((Double) rand.nextDouble()).toString()).setScale((short) typeInfo.scale()));
         }
 
-        if(dcv.vector[i].doubleValue() == 0) {
+        if(dcv.vector[i].getHiveDecimal().doubleValue() == 0) {
           i--;
         }
       }

Modified: hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestInputOutputFormat.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestInputOutputFormat.java?rev=1636055&r1=1636054&r2=1636055&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestInputOutputFormat.java (original)
+++ hive/branches/branch-0.14/ql/src/test/org/apache/hadoop/hive/ql/io/orc/TestInputOutputFormat.java Sat Nov  1 21:10:32 2014
@@ -51,7 +51,6 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.hadoop.hive.common.type.Decimal128;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
@@ -1466,8 +1465,8 @@ public class TestInputOutputFormat {
       assertEquals("checking double " + i, i, doubleCoulmn.vector[i], 0.0001);
       assertEquals("checking string " + i, new Text(Long.toHexString(i)),
           stringColumn.getWritableObject(i));
-      assertEquals("checking decimal " + i, new Decimal128(i),
-          decimalColumn.vector[i]);
+      assertEquals("checking decimal " + i, HiveDecimal.create(i),
+          decimalColumn.vector[i].getHiveDecimal());
       assertEquals("checking date " + i, i, dateColumn.vector[i]);
       long millis = (long) i * MILLIS_IN_DAY;
       millis -= LOCAL_TIMEZONE.getOffset(millis);

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_aggregate_9.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_aggregate_9.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_aggregate_9.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_aggregate_9.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,43 @@
+SET hive.vectorized.execution.enabled=true;
+
+create table vectortab2k(
+            t tinyint,
+            si smallint,
+            i int,
+            b bigint,
+            f float,
+            d double,
+            dc decimal(38,18),
+            bo boolean,
+            s string,
+            s2 string,
+            ts timestamp,
+            ts2 timestamp,
+            dt date)
+ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
+STORED AS TEXTFILE;
+
+LOAD DATA LOCAL INPATH '../../data/files/vectortab2k' OVERWRITE INTO TABLE vectortab2k;
+
+create table vectortab2korc(
+            t tinyint,
+            si smallint,
+            i int,
+            b bigint,
+            f float,
+            d double,
+            dc decimal(38,18),
+            bo boolean,
+            s string,
+            s2 string,
+            ts timestamp,
+            ts2 timestamp,
+            dt date)
+STORED AS ORC;
+
+INSERT INTO TABLE vectortab2korc SELECT * FROM vectortab2k;
+
+explain
+select min(dc), max(dc), sum(dc), avg(dc) from vectortab2korc;
+
+select min(dc), max(dc), sum(dc), avg(dc) from vectortab2korc;
\ No newline at end of file

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_1.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_1.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_1.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_1.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,58 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+drop table if exists decimal_1;
+
+create table decimal_1 (t decimal(4,2), u decimal(5), v decimal) stored as orc;
+
+desc decimal_1;
+
+insert overwrite table decimal_1
+  select cast('17.29' as decimal(4,2)), 3.1415926BD, 3115926.54321BD from src tablesample (1 rows);
+
+explain
+select cast(t as boolean) from decimal_1 order by t;
+
+select cast(t as boolean) from decimal_1 order by t;
+
+explain
+select cast(t as tinyint) from decimal_1 order by t;
+
+select cast(t as tinyint) from decimal_1 order by t;
+
+explain
+select cast(t as smallint) from decimal_1 order by t;
+
+select cast(t as smallint) from decimal_1 order by t;
+
+explain
+select cast(t as int) from decimal_1 order by t;
+
+select cast(t as int) from decimal_1 order by t;
+
+explain
+select cast(t as bigint) from decimal_1 order by t;
+
+select cast(t as bigint) from decimal_1 order by t;
+
+explain
+select cast(t as float) from decimal_1 order by t;
+
+select cast(t as float) from decimal_1 order by t;
+
+explain
+select cast(t as double) from decimal_1 order by t;
+
+select cast(t as double) from decimal_1 order by t;
+
+explain
+select cast(t as string) from decimal_1 order by t;
+
+select cast(t as string) from decimal_1 order by t;
+
+explain
+select cast(t as timestamp) from decimal_1 order by t;
+
+select cast(t as timestamp) from decimal_1 order by t;
+
+drop table decimal_1;
\ No newline at end of file

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_10_0.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_10_0.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_10_0.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_10_0.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,19 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+DROP TABLE IF EXISTS decimal_txt;
+DROP TABLE IF EXISTS decimal;
+
+CREATE TABLE decimal_txt (dec decimal);
+
+LOAD DATA LOCAL INPATH '../../data/files/decimal_10_0.txt' OVERWRITE INTO TABLE decimal_txt;
+
+CREATE TABLE DECIMAL STORED AS ORC AS SELECT * FROM decimal_txt;
+
+EXPLAIN
+SELECT dec FROM DECIMAL order by dec;
+
+SELECT dec FROM DECIMAL order by dec;
+
+DROP TABLE DECIMAL_txt;
+DROP TABLE DECIMAL;
\ No newline at end of file

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_2.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_2.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_2.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_2.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,146 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+drop table decimal_2;
+
+create table decimal_2 (t decimal(18,9)) stored as orc;
+
+insert overwrite table decimal_2
+  select cast('17.29' as decimal(4,2)) from src tablesample (1 rows);
+
+explain
+select cast(t as boolean) from decimal_2 order by t;
+
+select cast(t as boolean) from decimal_2 order by t;
+
+explain
+select cast(t as tinyint) from decimal_2 order by t;
+
+select cast(t as tinyint) from decimal_2 order by t;
+
+explain
+select cast(t as smallint) from decimal_2 order by t;
+
+select cast(t as smallint) from decimal_2 order by t;
+
+explain
+select cast(t as int) from decimal_2 order by t;
+
+select cast(t as int) from decimal_2 order by t;
+
+explain
+select cast(t as bigint) from decimal_2 order by t;
+
+select cast(t as bigint) from decimal_2 order by t;
+
+explain
+select cast(t as float) from decimal_2 order by t;
+
+select cast(t as float) from decimal_2 order by t;
+
+explain
+select cast(t as double) from decimal_2 order by t;
+
+select cast(t as double) from decimal_2 order by t;
+
+explain
+select cast(t as string) from decimal_2 order by t;
+
+select cast(t as string) from decimal_2 order by t;
+
+insert overwrite table decimal_2
+  select cast('3404045.5044003' as decimal(18,9)) from src tablesample (1 rows);
+
+explain
+select cast(t as boolean) from decimal_2 order by t;
+
+select cast(t as boolean) from decimal_2 order by t;
+
+explain
+select cast(t as tinyint) from decimal_2 order by t;
+
+select cast(t as tinyint) from decimal_2 order by t;
+
+explain
+select cast(t as smallint) from decimal_2 order by t;
+
+select cast(t as smallint) from decimal_2 order by t;
+
+explain
+select cast(t as int) from decimal_2 order by t;
+
+select cast(t as int) from decimal_2 order by t;
+
+explain
+select cast(t as bigint) from decimal_2 order by t;
+
+select cast(t as bigint) from decimal_2 order by t;
+
+explain
+select cast(t as float) from decimal_2 order by t;
+
+select cast(t as float) from decimal_2 order by t;
+
+explain
+select cast(t as double) from decimal_2 order by t;
+
+select cast(t as double) from decimal_2 order by t;
+
+explain
+select cast(t as string) from decimal_2 order by t;
+
+select cast(t as string) from decimal_2 order by t;
+
+explain
+select cast(3.14 as decimal(4,2)) as c from decimal_2 order by c;
+
+select cast(3.14 as decimal(4,2)) as c from decimal_2 order by c;
+
+explain
+select cast(cast(3.14 as float) as decimal(4,2)) as c from decimal_2 order by c;
+
+select cast(cast(3.14 as float) as decimal(4,2)) as c from decimal_2 order by c;
+
+explain
+select cast(cast('2012-12-19 11:12:19.1234567' as timestamp) as decimal(30,8)) as c from decimal_2 order by c;
+
+select cast(cast('2012-12-19 11:12:19.1234567' as timestamp) as decimal(30,8)) as c from decimal_2 order by c;
+
+explain
+select cast(true as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(true as decimal) as c from decimal_2 order by c;
+
+select cast(true as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(3Y as decimal) as c from decimal_2 order by c;
+
+select cast(3Y as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(3S as decimal) as c from decimal_2 order by c;
+
+select cast(3S as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(cast(3 as int) as decimal) as c from decimal_2 order by c;
+
+select cast(cast(3 as int) as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(3L as decimal) as c from decimal_2 order by c;
+
+select cast(3L as decimal) as c from decimal_2 order by c;
+
+explain
+select cast(0.99999999999999999999 as decimal(20,19)) as c from decimal_2 order by c;
+
+select cast(0.99999999999999999999 as decimal(20,19)) as c from decimal_2 order by c;
+
+explain
+select cast('0.99999999999999999999' as decimal(20,20)) as c from decimal_2 order by c;
+
+select cast('0.99999999999999999999' as decimal(20,20)) as c from decimal_2 order by c;
+drop table decimal_2;

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_3.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_3.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_3.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_3.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,35 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+DROP TABLE IF EXISTS DECIMAL_3_txt;
+DROP TABLE IF EXISTS DECIMAL_3;
+
+CREATE TABLE DECIMAL_3_txt(key decimal(38,18), value int)
+ROW FORMAT DELIMITED
+   FIELDS TERMINATED BY ' '
+STORED AS TEXTFILE;
+
+LOAD DATA LOCAL INPATH '../../data/files/kv7.txt' INTO TABLE DECIMAL_3_txt;
+
+CREATE TABLE DECIMAL_3 STORED AS ORC AS SELECT * FROM DECIMAL_3_txt;
+
+SELECT * FROM DECIMAL_3 ORDER BY key, value;
+
+SELECT * FROM DECIMAL_3 ORDER BY key DESC, value DESC;
+
+SELECT * FROM DECIMAL_3 ORDER BY key, value;
+
+SELECT DISTINCT key FROM DECIMAL_3 ORDER BY key;
+
+SELECT key, sum(value) FROM DECIMAL_3 GROUP BY key ORDER BY key;
+
+SELECT value, sum(key) FROM DECIMAL_3 GROUP BY value ORDER BY value;
+
+SELECT * FROM DECIMAL_3 a JOIN DECIMAL_3 b ON (a.key = b.key) ORDER BY a.key, a.value, b.value;
+
+SELECT * FROM DECIMAL_3 WHERE key=3.14 ORDER BY key, value;
+
+SELECT * FROM DECIMAL_3 WHERE key=3.140 ORDER BY key, value;
+
+DROP TABLE DECIMAL_3_txt;
+DROP TABLE DECIMAL_3;

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_4.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_4.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_4.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_4.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,28 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+DROP TABLE IF EXISTS DECIMAL_4_1;
+DROP TABLE IF EXISTS DECIMAL_4_2;
+
+CREATE TABLE DECIMAL_4_1(key decimal(35,25), value int) 
+ROW FORMAT DELIMITED
+   FIELDS TERMINATED BY ' '
+STORED AS TEXTFILE;
+
+CREATE TABLE DECIMAL_4_2(key decimal(35,25), value decimal(35,25)) 
+STORED AS ORC;
+
+LOAD DATA LOCAL INPATH '../../data/files/kv7.txt' INTO TABLE DECIMAL_4_1;
+
+INSERT OVERWRITE TABLE DECIMAL_4_2 SELECT key, key * 3 FROM DECIMAL_4_1;
+
+SELECT * FROM DECIMAL_4_1 ORDER BY key, value;
+
+SELECT * FROM DECIMAL_4_2 ORDER BY key, value;
+
+SELECT * FROM DECIMAL_4_2 ORDER BY key;
+
+SELECT * FROM DECIMAL_4_2 ORDER BY key, value;
+
+DROP TABLE DECIMAL_4_1;
+DROP TABLE DECIMAL_4_2;

Added: hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_5.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_5.q?rev=1636055&view=auto
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_5.q (added)
+++ hive/branches/branch-0.14/ql/src/test/queries/clientpositive/vector_decimal_5.q Sat Nov  1 21:10:32 2014
@@ -0,0 +1,28 @@
+SET hive.vectorized.execution.enabled=true;
+set hive.fetch.task.conversion=minimal;
+
+DROP TABLE IF EXISTS DECIMAL_5_txt;
+DROP TABLE IF EXISTS DECIMAL_5;
+
+CREATE TABLE DECIMAL_5_txt(key decimal(10,5), value int)
+ROW FORMAT DELIMITED
+   FIELDS TERMINATED BY ' '
+STORED AS TEXTFILE;
+
+LOAD DATA LOCAL INPATH '../../data/files/kv7.txt' INTO TABLE DECIMAL_5_txt;
+
+CREATE TABLE DECIMAL_5(key decimal(10,5), value int)
+STORED AS ORC;
+
+INSERT OVERWRITE TABLE DECIMAL_5 SELECT * FROM DECIMAL_5_txt;
+
+SELECT key FROM DECIMAL_5 ORDER BY key;
+
+SELECT DISTINCT key FROM DECIMAL_5 ORDER BY key;
+
+SELECT cast(key as decimal) FROM DECIMAL_5;
+
+SELECT cast(key as decimal(6,3)) FROM DECIMAL_5;
+
+DROP TABLE DECIMAL_5_txt;
+DROP TABLE DECIMAL_5;
\ No newline at end of file



Mime
View raw message