You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2016/12/04 00:45:40 UTC

[10/10] hive git commit: HIVE-15334: HIVE-13945 changed scale rules for division (Jason Dere, reviewed by Sergey Shelukhin)

HIVE-15334: HIVE-13945 changed scale rules for division (Jason Dere, reviewed by Sergey Shelukhin)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/eb5dde21
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/eb5dde21
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/eb5dde21

Branch: refs/heads/master
Commit: eb5dde2186850182d46e3897b48501e46e43922b
Parents: a625bb0
Author: Jason Dere <jd...@hortonworks.com>
Authored: Sat Dec 3 16:44:32 2016 -0800
Committer: Jason Dere <jd...@hortonworks.com>
Committed: Sat Dec 3 16:44:32 2016 -0800

----------------------------------------------------------------------
 .../hive/ql/udf/generic/GenericUDFOPDivide.java |    9 +-
 .../ql/udf/generic/TestGenericUDFOPDivide.java  |   54 +-
 .../clientpositive/ansi_sql_arithmetic.q.out    |    4 +-
 .../clientpositive/decimal_precision.q.out      |  186 ++--
 .../results/clientpositive/decimal_udf.q.out    |   72 +-
 .../llap/vector_decimal_expressions.q.out       |   26 +-
 .../llap/vector_decimal_precision.q.out         |  186 ++--
 .../llap/vector_decimal_udf.q.out               |   72 +-
 .../clientpositive/llap/vectorization_16.q.out  | 1046 +++++++++---------
 .../clientpositive/llap/vectorization_9.q.out   | 1046 +++++++++---------
 .../llap/vectorization_short_regress.q.out      |  412 +++----
 .../clientpositive/spark/vectorization_16.q.out | 1046 +++++++++---------
 .../clientpositive/spark/vectorization_9.q.out  | 1046 +++++++++---------
 .../spark/vectorization_short_regress.q.out     |  412 +++----
 .../vector_decimal_expressions.q.out            |   26 +-
 .../vector_decimal_precision.q.out              |  186 ++--
 .../clientpositive/vectorization_16.q.out       | 1046 +++++++++---------
 .../clientpositive/vectorization_9.q.out        | 1046 +++++++++---------
 18 files changed, 3958 insertions(+), 3963 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java
index 746d87a..89e69be 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java
@@ -110,24 +110,19 @@ public class GenericUDFOPDivide extends GenericUDFBaseNumeric {
     return decimalWritable;
   }
 
-  private final static int MIN_START_DEC_DIGITS = 6;
-  private final static int DEFAULT_DEC_DIGITS = 18;
   /**
    * A balanced way to determine the precision/scale of decimal division result. Integer digits and
    * decimal digits are computed independently. However, when the precision from above reaches above
-   * HiveDecimal.MAX_PRECISION, integer digit and decimal digits are shrunk equally to fit.
+   * HiveDecimal.MAX_PRECISION, interger digit and decimal digits are shrunk equally to fit.
    */
   @Override
   protected DecimalTypeInfo deriveResultDecimalTypeInfo(int prec1, int scale1, int prec2, int scale2) {
     int intDig = Math.min(HiveDecimal.MAX_SCALE, prec1 - scale1 + scale2);
-    int decDig = Math.min(HiveDecimal.MAX_SCALE,
-        Math.max(MIN_START_DEC_DIGITS, scale1 + prec2 + 1));
+    int decDig = Math.min(HiveDecimal.MAX_SCALE, Math.max(6, scale1 + prec2 + 1));
     int diff = intDig + decDig -  HiveDecimal.MAX_SCALE;
     if (diff > 0) {
       decDig -= diff/2 + 1; // Slight negative bias.
       intDig = HiveDecimal.MAX_SCALE - decDig;
-    } else if (diff < 0 && decDig < DEFAULT_DEC_DIGITS) {
-      decDig += Math.min(-diff, DEFAULT_DEC_DIGITS - decDig);
     }
     return TypeInfoFactory.getDecimalTypeInfo(intDig + decDig, decDig);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFOPDivide.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFOPDivide.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFOPDivide.java
index 59fb7dc..6fa3b3f 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFOPDivide.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFOPDivide.java
@@ -45,6 +45,7 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
   @Test
   public void testByteDivideShort() throws HiveException {
     GenericUDFOPDivide udf = new GenericUDFOPDivide();
+
     ByteWritable left = new ByteWritable((byte) 4);
     ShortWritable right = new ShortWritable((short) 6);
     ObjectInspector[] inputOIs = {
@@ -57,9 +58,9 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     };
 
     PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
-    Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.getDecimalTypeInfo(21, 18));
+    Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.getDecimalTypeInfo(9, 6));
     HiveDecimalWritable res = (HiveDecimalWritable) udf.evaluate(args);
-    Assert.assertEquals(HiveDecimal.create("0.666666666666666667"), res.getHiveDecimal());
+    Assert.assertEquals(HiveDecimal.create("0.666667"), res.getHiveDecimal());
   }
 
   @Test
@@ -108,12 +109,12 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
   @Test
   public void testLongDivideDecimal() throws HiveException {
     GenericUDFOPDivide udf = new GenericUDFOPDivide();
+
     LongWritable left = new LongWritable(104);
     HiveDecimalWritable right = new HiveDecimalWritable(HiveDecimal.create("234.97"));
     ObjectInspector[] inputOIs = {
         PrimitiveObjectInspectorFactory.writableLongObjectInspector,
-        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
-            TypeInfoFactory.getDecimalTypeInfo(38, 15))
+        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(9, 4))
     };
     DeferredObject[] args = {
         new DeferredJavaObject(left),
@@ -121,9 +122,9 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     };
 
     PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
-    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(38, 20), oi.getTypeInfo());
+    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(33, 10), oi.getTypeInfo());
     HiveDecimalWritable res = (HiveDecimalWritable) udf.evaluate(args);
-    Assert.assertEquals(HiveDecimal.create("0.44260969485466229731"), res.getHiveDecimal());
+    Assert.assertEquals(HiveDecimal.create("0.4426096949"), res.getHiveDecimal());
   }
 
   @Test
@@ -148,7 +149,7 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
   }
 
   @Test
-  public void testDoubleDivideDecimal() throws HiveException {
+  public void testDouleDivideDecimal() throws HiveException {
     GenericUDFOPDivide udf = new GenericUDFOPDivide();
 
     DoubleWritable left = new DoubleWritable(74.52);
@@ -175,25 +176,24 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     HiveDecimalWritable left = new HiveDecimalWritable(HiveDecimal.create("14.5"));
     HiveDecimalWritable right = new HiveDecimalWritable(HiveDecimal.create("234.97"));
     ObjectInspector[] inputOIs = {
-        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
-            TypeInfoFactory.getDecimalTypeInfo(3, 1)),
-        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
-            TypeInfoFactory.getDecimalTypeInfo(5, 2))
+        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(3, 1)),
+        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(5, 2))
     };
     DeferredObject[] args = {
         new DeferredJavaObject(left),
         new DeferredJavaObject(right),
     };
- 
+
     PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
-    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(22, 18), oi.getTypeInfo());
+    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(11, 7), oi.getTypeInfo());
     HiveDecimalWritable res = (HiveDecimalWritable) udf.evaluate(args);
-    Assert.assertEquals(HiveDecimal.create("0.061710005532621186"), res.getHiveDecimal());
+    Assert.assertEquals(HiveDecimal.create("0.06171"), res.getHiveDecimal());
   }
 
   @Test
   public void testDecimalDivideDecimal2() throws HiveException {
     GenericUDFOPDivide udf = new GenericUDFOPDivide();
+
     HiveDecimalWritable left = new HiveDecimalWritable(HiveDecimal.create("5"));
     HiveDecimalWritable right = new HiveDecimalWritable(HiveDecimal.create("25"));
     ObjectInspector[] inputOIs = {
@@ -206,7 +206,7 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     };
 
     PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
-    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(19, 18), oi.getTypeInfo());
+    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(7, 6), oi.getTypeInfo());
     HiveDecimalWritable res = (HiveDecimalWritable) udf.evaluate(args);
     Assert.assertEquals(HiveDecimal.create("0.2"), res.getHiveDecimal());
   }
@@ -221,19 +221,19 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     };
 
     PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
-    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(23, 18), oi.getTypeInfo());
+    Assert.assertEquals(TypeInfoFactory.getDecimalTypeInfo(13, 8), oi.getTypeInfo());
   }
 
   @Test
   public void testDecimalDivisionResultType() throws HiveException {
-    testDecimalDivisionResultType(5, 2, 3, 2, 23, 18);
+    testDecimalDivisionResultType(5, 2, 3, 2, 11, 6);
     testDecimalDivisionResultType(38, 18, 38, 18, 38, 18);
     testDecimalDivisionResultType(38, 18, 20, 0, 38, 27);
-    testDecimalDivisionResultType(20, 0, 8, 5, 38, 13);
-    testDecimalDivisionResultType(10, 0, 10, 0, 28, 18);
-    testDecimalDivisionResultType(5, 2, 5, 5, 26, 18);
-    testDecimalDivisionResultType(10, 10, 5, 0, 18, 18);
-    testDecimalDivisionResultType(10, 10, 5, 5, 23, 18);
+    testDecimalDivisionResultType(20, 0, 8, 5, 34, 9);
+    testDecimalDivisionResultType(10, 0, 10, 0, 21, 11);
+    testDecimalDivisionResultType(5, 2, 5, 5, 16, 8);
+    testDecimalDivisionResultType(10, 10, 5, 0, 16, 16);
+    testDecimalDivisionResultType(10, 10, 5, 5, 21, 16);
     testDecimalDivisionResultType(38, 38, 38, 38, 38, 18);
     testDecimalDivisionResultType(38, 0, 38, 0, 38, 18);
   }
@@ -259,7 +259,7 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     verifyReturnType(new GenericUDFOPDivide(), "int", "int", "double"); // different from sql compat mode
     verifyReturnType(new GenericUDFOPDivide(), "int", "float", "double");
     verifyReturnType(new GenericUDFOPDivide(), "int", "double", "double");
-    verifyReturnType(new GenericUDFOPDivide(), "int", "decimal(10,2)", "decimal(30,18)");
+    verifyReturnType(new GenericUDFOPDivide(), "int", "decimal(10,2)", "decimal(23,11)");
 
     verifyReturnType(new GenericUDFOPDivide(), "float", "float", "double");
     verifyReturnType(new GenericUDFOPDivide(), "float", "double", "double");
@@ -268,7 +268,7 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     verifyReturnType(new GenericUDFOPDivide(), "double", "double", "double");
     verifyReturnType(new GenericUDFOPDivide(), "double", "decimal(10,2)", "double");
 
-    verifyReturnType(new GenericUDFOPDivide(), "decimal(10,2)", "decimal(10,2)", "decimal(28,18)");
+    verifyReturnType(new GenericUDFOPDivide(), "decimal(10,2)", "decimal(10,2)", "decimal(23,13)");
 
     // Most tests are done with ANSI SQL mode enabled, set it back to true
     SessionState.get().getConf().setVar(HiveConf.ConfVars.HIVE_COMPAT, "latest");
@@ -278,10 +278,10 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
   public void testReturnTypeAnsiSql() throws Exception {
     SessionState.get().getConf().setVar(HiveConf.ConfVars.HIVE_COMPAT, "latest");
 
-    verifyReturnType(new GenericUDFOPDivide(), "int", "int", "decimal(28,18)");
+    verifyReturnType(new GenericUDFOPDivide(), "int", "int", "decimal(21,11)");
     verifyReturnType(new GenericUDFOPDivide(), "int", "float", "double");
     verifyReturnType(new GenericUDFOPDivide(), "int", "double", "double");
-    verifyReturnType(new GenericUDFOPDivide(), "int", "decimal(10,2)", "decimal(30,18)");
+    verifyReturnType(new GenericUDFOPDivide(), "int", "decimal(10,2)", "decimal(23,11)");
 
     verifyReturnType(new GenericUDFOPDivide(), "float", "float", "double");
     verifyReturnType(new GenericUDFOPDivide(), "float", "double", "double");
@@ -290,6 +290,6 @@ public class TestGenericUDFOPDivide extends AbstractTestGenericUDFOPNumeric {
     verifyReturnType(new GenericUDFOPDivide(), "double", "double", "double");
     verifyReturnType(new GenericUDFOPDivide(), "double", "decimal(10,2)", "double");
 
-    verifyReturnType(new GenericUDFOPDivide(), "decimal(10,2)", "decimal(10,2)", "decimal(28,18)");
+    verifyReturnType(new GenericUDFOPDivide(), "decimal(10,2)", "decimal(10,2)", "decimal(23,13)");
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/ansi_sql_arithmetic.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/ansi_sql_arithmetic.q.out b/ql/src/test/results/clientpositive/ansi_sql_arithmetic.q.out
index 7d345fc..dd12b02 100644
--- a/ql/src/test/results/clientpositive/ansi_sql_arithmetic.q.out
+++ b/ql/src/test/results/clientpositive/ansi_sql_arithmetic.q.out
@@ -16,7 +16,7 @@ STAGE PLANS:
             alias: src
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: (CAST( UDFToInteger(key) AS decimal(10,0)) / CAST( UDFToInteger(key) AS decimal(10,0))) (type: decimal(28,18))
+              expressions: (CAST( UDFToInteger(key) AS decimal(10,0)) / CAST( UDFToInteger(key) AS decimal(10,0))) (type: decimal(21,11))
               outputColumnNames: _col0
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
               Limit
@@ -44,7 +44,7 @@ POSTHOOK: query: select cast(key as int) / cast(key as int) from src limit 1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-1.000000000000000000
+1.00000000000
 PREHOOK: query: -- With ansi sql arithmetic disabled, int / int => double
 explain select cast(key as int) / cast(key as int) from src limit 1
 PREHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/decimal_precision.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/decimal_precision.q.out b/ql/src/test/results/clientpositive/decimal_precision.q.out
index a607d9f..3baeb8e 100644
--- a/ql/src/test/results/clientpositive/decimal_precision.q.out
+++ b/ql/src/test/results/clientpositive/decimal_precision.q.out
@@ -242,37 +242,37 @@ NULL	NULL	NULL
 NULL	NULL	NULL
 NULL	NULL	NULL
 NULL	NULL	NULL
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.1234567890	0.2469135780	0.041152263000000000
-0.1234567890	0.2469135780	0.041152263000000000
-1.2345678901	2.4691357802	0.411522630033333333
-1.2345678901	2.4691357802	0.411522630033333333
-1.2345678901	2.4691357802	0.411522630033333333
-12.3456789012	24.6913578024	4.115226300400000000
-12.3456789012	24.6913578024	4.115226300400000000
-12.3456789012	24.6913578024	4.115226300400000000
-123.4567890123	246.9135780246	41.152263004100000000
-123.4567890123	246.9135780246	41.152263004100000000
-123.4567890123	246.9135780246	41.152263004100000000
-1234.5678901235	2469.1357802470	411.522630041166666667
-1234.5678901235	2469.1357802470	411.522630041166666667
-1234.5678901235	2469.1357802470	411.522630041166666667
-12345.6789012346	24691.3578024692	4115.226300411533333333
-12345.6789012346	24691.3578024692	4115.226300411533333333
-123456.7890123456	246913.5780246912	41152.263004115200000000
-123456.7890123457	246913.5780246914	41152.263004115233333333
-1234567.8901234560	2469135.7802469120	411522.630041152000000000
-1234567.8901234568	2469135.7802469136	411522.630041152266666667
-12345678.9012345600	24691357.8024691200	4115226.300411520000000000
-12345678.9012345679	24691357.8024691358	4115226.300411522633333333
-123456789.0123456000	246913578.0246912000	41152263.004115200000000000
-123456789.0123456789	246913578.0246913578	41152263.004115226300000000
-1234567890.1234560000	2469135780.2469120000	411522630.041152000000000000
-1234567890.1234567890	2469135780.2469135780	411522630.041152263000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.1234567890	0.2469135780	0.041152263000
+0.1234567890	0.2469135780	0.041152263000
+1.2345678901	2.4691357802	0.411522630033
+1.2345678901	2.4691357802	0.411522630033
+1.2345678901	2.4691357802	0.411522630033
+12.3456789012	24.6913578024	4.115226300400
+12.3456789012	24.6913578024	4.115226300400
+12.3456789012	24.6913578024	4.115226300400
+123.4567890123	246.9135780246	41.152263004100
+123.4567890123	246.9135780246	41.152263004100
+123.4567890123	246.9135780246	41.152263004100
+1234.5678901235	2469.1357802470	411.522630041167
+1234.5678901235	2469.1357802470	411.522630041167
+1234.5678901235	2469.1357802470	411.522630041167
+12345.6789012346	24691.3578024692	4115.226300411533
+12345.6789012346	24691.3578024692	4115.226300411533
+123456.7890123456	246913.5780246912	41152.263004115200
+123456.7890123457	246913.5780246914	41152.263004115233
+1234567.8901234560	2469135.7802469120	411522.630041152000
+1234567.8901234568	2469135.7802469136	411522.630041152267
+12345678.9012345600	24691357.8024691200	4115226.300411520000
+12345678.9012345679	24691357.8024691358	4115226.300411522633
+123456789.0123456000	246913578.0246912000	41152263.004115200000
+123456789.0123456789	246913578.0246913578	41152263.004115226300
+1234567890.1234560000	2469135780.2469120000	411522630.041152000000
+1234567890.1234567890	2469135780.2469135780	411522630.041152263000
 PREHOOK: query: SELECT dec, dec / 9 FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision
@@ -325,37 +325,37 @@ NULL	NULL
 NULL	NULL
 NULL	NULL
 NULL	NULL
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.1234567890	0.013717421000000000
-0.1234567890	0.013717421000000000
-1.2345678901	0.137174210011111111
-1.2345678901	0.137174210011111111
-1.2345678901	0.137174210011111111
-12.3456789012	1.371742100133333333
-12.3456789012	1.371742100133333333
-12.3456789012	1.371742100133333333
-123.4567890123	13.717421001366666667
-123.4567890123	13.717421001366666667
-123.4567890123	13.717421001366666667
-1234.5678901235	137.174210013722222222
-1234.5678901235	137.174210013722222222
-1234.5678901235	137.174210013722222222
-12345.6789012346	1371.742100137177777778
-12345.6789012346	1371.742100137177777778
-123456.7890123456	13717.421001371733333333
-123456.7890123457	13717.421001371744444444
-1234567.8901234560	137174.210013717333333333
-1234567.8901234568	137174.210013717422222222
-12345678.9012345600	1371742.100137173333333333
-12345678.9012345679	1371742.100137174211111111
-123456789.0123456000	13717421.001371733333333333
-123456789.0123456789	13717421.001371742100000000
-1234567890.1234560000	137174210.013717333333333333
-1234567890.1234567890	137174210.013717421000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.1234567890	0.013717421000
+0.1234567890	0.013717421000
+1.2345678901	0.137174210011
+1.2345678901	0.137174210011
+1.2345678901	0.137174210011
+12.3456789012	1.371742100133
+12.3456789012	1.371742100133
+12.3456789012	1.371742100133
+123.4567890123	13.717421001367
+123.4567890123	13.717421001367
+123.4567890123	13.717421001367
+1234.5678901235	137.174210013722
+1234.5678901235	137.174210013722
+1234.5678901235	137.174210013722
+12345.6789012346	1371.742100137178
+12345.6789012346	1371.742100137178
+123456.7890123456	13717.421001371733
+123456.7890123457	13717.421001371744
+1234567.8901234560	137174.210013717333
+1234567.8901234568	137174.210013717422
+12345678.9012345600	1371742.100137173333
+12345678.9012345679	1371742.100137174211
+123456789.0123456000	13717421.001371733333
+123456789.0123456789	13717421.001371742100
+1234567890.1234560000	137174210.013717333333
+1234567890.1234567890	137174210.013717421000
 PREHOOK: query: SELECT dec, dec / 27 FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision
@@ -408,37 +408,37 @@ NULL	NULL
 NULL	NULL
 NULL	NULL
 NULL	NULL
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.1234567890	0.004572473666666667
-0.1234567890	0.004572473666666667
-1.2345678901	0.045724736670370370
-1.2345678901	0.045724736670370370
-1.2345678901	0.045724736670370370
-12.3456789012	0.457247366711111111
-12.3456789012	0.457247366711111111
-12.3456789012	0.457247366711111111
-123.4567890123	4.572473667122222222
-123.4567890123	4.572473667122222222
-123.4567890123	4.572473667122222222
-1234.5678901235	45.724736671240740741
-1234.5678901235	45.724736671240740741
-1234.5678901235	45.724736671240740741
-12345.6789012346	457.247366712392592593
-12345.6789012346	457.247366712392592593
-123456.7890123456	4572.473667123911111111
-123456.7890123457	4572.473667123914814815
-1234567.8901234560	45724.736671239111111111
-1234567.8901234568	45724.736671239140740741
-12345678.9012345600	457247.366712391111111111
-12345678.9012345679	457247.366712391403703704
-123456789.0123456000	4572473.667123911111111111
-123456789.0123456789	4572473.667123914033333333
-1234567890.1234560000	45724736.671239111111111111
-1234567890.1234567890	45724736.671239140333333333
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.1234567890	0.0045724736667
+0.1234567890	0.0045724736667
+1.2345678901	0.0457247366704
+1.2345678901	0.0457247366704
+1.2345678901	0.0457247366704
+12.3456789012	0.4572473667111
+12.3456789012	0.4572473667111
+12.3456789012	0.4572473667111
+123.4567890123	4.5724736671222
+123.4567890123	4.5724736671222
+123.4567890123	4.5724736671222
+1234.5678901235	45.7247366712407
+1234.5678901235	45.7247366712407
+1234.5678901235	45.7247366712407
+12345.6789012346	457.2473667123926
+12345.6789012346	457.2473667123926
+123456.7890123456	4572.4736671239111
+123456.7890123457	4572.4736671239148
+1234567.8901234560	45724.7366712391111
+1234567.8901234568	45724.7366712391407
+12345678.9012345600	457247.3667123911111
+12345678.9012345679	457247.3667123914037
+123456789.0123456000	4572473.6671239111111
+123456789.0123456789	4572473.6671239140333
+1234567890.1234560000	45724736.6712391111111
+1234567890.1234567890	45724736.6712391403333
 PREHOOK: query: SELECT dec, dec * dec FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/decimal_udf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/decimal_udf.q.out b/ql/src/test/results/clientpositive/decimal_udf.q.out
index 47d2103..c0baab8 100644
--- a/ql/src/test/results/clientpositive/decimal_udf.q.out
+++ b/ql/src/test/results/clientpositive/decimal_udf.q.out
@@ -907,7 +907,7 @@ STAGE PLANS:
           alias: decimal_udf
           Statistics: Num rows: 3 Data size: 359 Basic stats: COMPLETE Column stats: NONE
           Select Operator
-            expressions: (key / 0) (type: decimal(28,18))
+            expressions: (key / 0) (type: decimal(22,12))
             outputColumnNames: _col0
             Statistics: Num rows: 3 Data size: 359 Basic stats: COMPLETE Column stats: NONE
             Limit
@@ -1808,7 +1808,7 @@ STAGE PLANS:
           alias: decimal_udf
           Statistics: Num rows: 3 Data size: 359 Basic stats: COMPLETE Column stats: NONE
           Select Operator
-            expressions: ((key + 1) % (key / 2)) (type: decimal(28,18))
+            expressions: ((key + 1) % (key / 2)) (type: decimal(22,12))
             outputColumnNames: _col0
             Statistics: Num rows: 3 Data size: 359 Basic stats: COMPLETE Column stats: NONE
             ListSink
@@ -1821,44 +1821,44 @@ POSTHOOK: query: SELECT (key + 1) % (key / 2) FROM DECIMAL_UDF
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@decimal_udf
 #### A masked pattern was here ####
--2199.000000000000000000
+-2199.000000000000
 NULL
 NULL
 NULL
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
-0.000000000000000000
-0.000000000000000000
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
+1.000000000000
+1.000000000000
+0.000000000000
+0.000000000000
+0.000000000000
+1.000000000000
+1.000000000000
+0.000000000000
 NULL
-0.000000000000000000
-0.000000000000000000
-0.100000000000000000
-0.010000000000000000
-0.001000000000000000
-0.100000000000000000
-0.010000000000000000
-0.001000000000000000
-0.000000000000000000
-0.000000000000000000
-1.000000000000000000
--0.120000000000000000
--0.120000000000000000
--0.122000000000000000
-0.440000000000000000
-0.439000000000000000
-1.000000000000000000
-1.000000000000000000
--626.745000000000000000
-1.000000000000000000
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
--617283944.061728394500000000
-1.000000000000000000
+0.000000000000
+0.000000000000
+0.100000000000
+0.010000000000
+0.001000000000
+0.100000000000
+0.010000000000
+0.001000000000
+0.000000000000
+0.000000000000
+1.000000000000
+-0.120000000000
+-0.120000000000
+-0.122000000000
+0.440000000000
+0.439000000000
+1.000000000000
+1.000000000000
+-626.745000000000
+1.000000000000
+1.000000000000
+1.000000000000
+0.000000000000
+-617283944.061728394500
+1.000000000000
 PREHOOK: query: -- stddev, var
 EXPLAIN SELECT value, stddev(key), variance(key) FROM DECIMAL_UDF GROUP BY value
 PREHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out b/ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out
index d37b973..bce4b12 100644
--- a/ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out
@@ -44,11 +44,11 @@ STAGE PLANS:
                     predicate: ((cdecimal1 > 0) and (cdecimal1 < 12345.5678) and (cdecimal2 <> 0) and (cdecimal2 > 1000) and cdouble is not null) (type: boolean)
                     Statistics: Num rows: 455 Data size: 78809 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: (cdecimal1 + cdecimal2) (type: decimal(25,14)), (cdecimal1 - (2 * cdecimal2)) (type: decimal(26,14)), ((cdecimal1 + 2.34) / cdecimal2) (type: decimal(38,23)), (cdecimal1 * (cdecimal2 / 3.4)) (type: decimal(38,28)), (cdecimal1 % 10) (type: decimal(12,10)), UDFToInteger(cdecimal1) (type: int), UDFToShort(cdecimal2) (type: smallint), UDFToByte(cdecimal2) (type: tinyint), UDFToLong(cdecimal1) (type: bigint), UDFToBoolean(cdecimal1) (type: boolean), UDFToDouble(cdecimal2) (type: double), UDFToFloat(cdecimal1) (type: float), UDFToString(cdecimal2) (type: string), CAST( cdecimal1 AS TIMESTAMP) (type: timestamp)
+                      expressions: (cdecimal1 + cdecimal2) (type: decimal(25,14)), (cdecimal1 - (2 * cdecimal2)) (type: decimal(26,14)), ((cdecimal1 + 2.34) / cdecimal2) (type: decimal(38,23)), (cdecimal1 * (cdecimal2 / 3.4)) (type: decimal(38,27)), (cdecimal1 % 10) (type: decimal(12,10)), UDFToInteger(cdecimal1) (type: int), UDFToShort(cdecimal2) (type: smallint), UDFToByte(cdecimal2) (type: tinyint), UDFToLong(cdecimal1) (type: bigint), UDFToBoolean(cdecimal1) (type: boolean), UDFToDouble(cdecimal2) (type: double), UDFToFloat(cdecimal1) (type: float), UDFToString(cdecimal2) (type: string), CAST( cdecimal1 AS TIMESTAMP) (type: timestamp)
                       outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13
                       Statistics: Num rows: 455 Data size: 78809 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
-                        key expressions: _col0 (type: decimal(25,14)), _col1 (type: decimal(26,14)), _col2 (type: decimal(38,23)), _col3 (type: decimal(38,28)), _col4 (type: decimal(12,10)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp)
+                        key expressions: _col0 (type: decimal(25,14)), _col1 (type: decimal(26,14)), _col2 (type: decimal(38,23)), _col3 (type: decimal(38,27)), _col4 (type: decimal(12,10)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp)
                         sort order: ++++++++++++++
                         Statistics: Num rows: 455 Data size: 78809 Basic stats: COMPLETE Column stats: NONE
                         TopN Hash Memory Usage: 0.1
@@ -58,7 +58,7 @@ STAGE PLANS:
             Execution mode: vectorized, llap
             Reduce Operator Tree:
               Select Operator
-                expressions: KEY.reducesinkkey0 (type: decimal(25,14)), KEY.reducesinkkey1 (type: decimal(26,14)), KEY.reducesinkkey2 (type: decimal(38,23)), KEY.reducesinkkey3 (type: decimal(38,28)), KEY.reducesinkkey4 (type: decimal(12,10)), KEY.reducesinkkey5 (type: int), KEY.reducesinkkey6 (type: smallint), KEY.reducesinkkey7 (type: tinyint), KEY.reducesinkkey8 (type: bigint), KEY.reducesinkkey9 (type: boolean), KEY.reducesinkkey10 (type: double), KEY.reducesinkkey11 (type: float), KEY.reducesinkkey12 (type: string), KEY.reducesinkkey13 (type: timestamp)
+                expressions: KEY.reducesinkkey0 (type: decimal(25,14)), KEY.reducesinkkey1 (type: decimal(26,14)), KEY.reducesinkkey2 (type: decimal(38,23)), KEY.reducesinkkey3 (type: decimal(38,27)), KEY.reducesinkkey4 (type: decimal(12,10)), KEY.reducesinkkey5 (type: int), KEY.reducesinkkey6 (type: smallint), KEY.reducesinkkey7 (type: tinyint), KEY.reducesinkkey8 (type: bigint), KEY.reducesinkkey9 (type: boolean), KEY.reducesinkkey10 (type: double), KEY.reducesinkkey11 (type: float), KEY.reducesinkkey12 (type: string), KEY.reducesinkkey13 (type: timestamp)
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13
                 Statistics: Num rows: 455 Data size: 78809 Basic stats: COMPLETE Column stats: NONE
                 Limit
@@ -90,13 +90,13 @@ LIMIT 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@decimal_test
 #### A masked pattern was here ####
-1836.44199584197700	-1166.02723492725400	0.83726978148337131458955	245972.5581081025580455294364554849	5.6189189189	835	1000	-24	835	true	1000.823076923077	835.6189	1000.823076923077	1969-12-31 16:13:55.618918918
-1856.13222453224620	-1178.52931392929240	0.83724497870140374273038	251275.4432432496874832128177818760	4.5783783784	844	1011	-13	844	true	1011.5538461538462	844.57837	1011.5538461538462	1969-12-31 16:14:04.578378378
-1858.75758835761550	-1180.19625779623100	0.83724171136694298221079	251986.7675675756486118069543362480	5.7729729730	845	1012	-12	845	true	1012.9846153846155	845.77295	1012.9846153846155	1969-12-31 16:14:05.772972973
-1862.69563409566930	-1182.69667359663860	0.83723682763446158861586	253055.6391891996966694739599371224	7.5648648649	847	1015	-9	847	true	1015.1307692307693	847.5649	1015.1307692307693	1969-12-31 16:14:07.564864864
-1883.69854469852330	-1196.03222453224660	0.83721112592864992485015	258794.4932432367711690165346689984	7.1216216216	857	1026	2	857	true	1026.5769230769233	857.12164	1026.5769230769233	1969-12-31 16:14:17.121621621
-1886.32390852389240	-1197.69916839918480	0.83720795345819015087813	259516.3743243194445698729852508744	8.3162162162	858	1028	4	858	true	1028.0076923076924	858.3162	1028.0076923076924	1969-12-31 16:14:18.316216216
-1887.63659043657700	-1198.53264033265400	0.83720637053221313673364	259877.6918918878226000553442090620	8.9135135135	858	1028	4	858	true	1028.723076923077	858.9135	1028.723076923077	1969-12-31 16:14:18.913513513
-1895.51268191268460	-1203.53347193346920	0.83719691901713431682002	262050.8756756764929300794233581876	2.4972972973	862	1033	9	862	true	1033.0153846153846	862.4973	1033.0153846153846	1969-12-31 16:14:22.497297297
-1909.95218295221550	-1212.70166320163100	0.83717979369462356311054	266058.5472973072557375360130254372	9.0675675676	869	1040	16	869	true	1040.8846153846155	869.06757	1040.8846153846155	1969-12-31 16:14:29.067567567
-1913.89022869026920	-1215.20207900203840	0.83717516799957965211367	267156.8270270394559195677611589825	0.8594594595	870	1043	19	870	true	1043.0307692307692	870.85944	1043.0307692307692	1969-12-31 16:14:30.859459459
+1836.44199584197700	-1166.02723492725400	0.83726978148337131458955	245972.558108102558044693817536566	5.6189189189	835	1000	-24	835	true	1000.823076923077	835.6189	1000.823076923077	1969-12-31 16:13:55.618918918
+1856.13222453224620	-1178.52931392929240	0.83724497870140374273038	251275.443243249687478989925889984	4.5783783784	844	1011	-13	844	true	1011.5538461538462	844.57837	1011.5538461538462	1969-12-31 16:14:04.578378378
+1858.75758835761550	-1180.19625779623100	0.83724171136694298221079	251986.767567575648615190046228140	5.7729729730	845	1012	-12	845	true	1012.9846153846155	845.77295	1012.9846153846155	1969-12-31 16:14:05.772972973
+1862.69563409566930	-1182.69667359663860	0.83723682763446158861586	253055.639189199696672864219396582	7.5648648649	847	1015	-9	847	true	1015.1307692307693	847.5649	1015.1307692307693	1969-12-31 16:14:07.564864864
+1883.69854469852330	-1196.03222453224660	0.83721112592864992485015	258794.493243236771165588048182512	7.1216216216	857	1026	2	857	true	1026.5769230769233	857.12164	1026.5769230769233	1969-12-31 16:14:17.121621621
+1886.32390852389240	-1197.69916839918480	0.83720795345819015087813	259516.374324319444568156352818442	8.3162162162	858	1028	4	858	true	1028.0076923076924	858.3162	1028.0076923076924	1969-12-31 16:14:18.316216216
+1887.63659043657700	-1198.53264033265400	0.83720637053221313673364	259877.691891887822598337517182035	8.9135135135	858	1028	4	858	true	1028.723076923077	858.9135	1028.723076923077	1969-12-31 16:14:18.913513513
+1895.51268191268460	-1203.53347193346920	0.83719691901713431682002	262050.875675676492928354428763593	2.4972972973	862	1033	9	862	true	1033.0153846153846	862.4973	1033.0153846153846	1969-12-31 16:14:22.497297297
+1909.95218295221550	-1212.70166320163100	0.83717979369462356311054	266058.547297307255740143215728140	9.0675675676	869	1040	16	869	true	1040.8846153846155	869.06757	1040.8846153846155	1969-12-31 16:14:29.067567567
+1913.89022869026920	-1215.20207900203840	0.83717516799957965211367	267156.827027039455923922058456280	0.8594594595	870	1043	19	870	true	1043.0307692307692	870.85944	1043.0307692307692	1969-12-31 16:14:30.859459459

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/llap/vector_decimal_precision.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_decimal_precision.q.out b/ql/src/test/results/clientpositive/llap/vector_decimal_precision.q.out
index 5583874..3c932e2 100644
--- a/ql/src/test/results/clientpositive/llap/vector_decimal_precision.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_decimal_precision.q.out
@@ -265,37 +265,37 @@ NULL	NULL	NULL
 NULL	NULL	NULL
 NULL	NULL	NULL
 NULL	NULL	NULL
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.0000000000	0.0000000000	0.000000000000000000
-0.1234567890	0.2469135780	0.041152263000000000
-0.1234567890	0.2469135780	0.041152263000000000
-1.2345678901	2.4691357802	0.411522630033333333
-1.2345678901	2.4691357802	0.411522630033333333
-1.2345678901	2.4691357802	0.411522630033333333
-12.3456789012	24.6913578024	4.115226300400000000
-12.3456789012	24.6913578024	4.115226300400000000
-12.3456789012	24.6913578024	4.115226300400000000
-123.4567890123	246.9135780246	41.152263004100000000
-123.4567890123	246.9135780246	41.152263004100000000
-123.4567890123	246.9135780246	41.152263004100000000
-1234.5678901235	2469.1357802470	411.522630041166666667
-1234.5678901235	2469.1357802470	411.522630041166666667
-1234.5678901235	2469.1357802470	411.522630041166666667
-12345.6789012346	24691.3578024692	4115.226300411533333333
-12345.6789012346	24691.3578024692	4115.226300411533333333
-123456.7890123456	246913.5780246912	41152.263004115200000000
-123456.7890123457	246913.5780246914	41152.263004115233333333
-1234567.8901234560	2469135.7802469120	411522.630041152000000000
-1234567.8901234568	2469135.7802469136	411522.630041152266666667
-12345678.9012345600	24691357.8024691200	4115226.300411520000000000
-12345678.9012345679	24691357.8024691358	4115226.300411522633333333
-123456789.0123456000	246913578.0246912000	41152263.004115200000000000
-123456789.0123456789	246913578.0246913578	41152263.004115226300000000
-1234567890.1234560000	2469135780.2469120000	411522630.041152000000000000
-1234567890.1234567890	2469135780.2469135780	411522630.041152263000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.0000000000	0.0000000000	0.000000000000
+0.1234567890	0.2469135780	0.041152263000
+0.1234567890	0.2469135780	0.041152263000
+1.2345678901	2.4691357802	0.411522630033
+1.2345678901	2.4691357802	0.411522630033
+1.2345678901	2.4691357802	0.411522630033
+12.3456789012	24.6913578024	4.115226300400
+12.3456789012	24.6913578024	4.115226300400
+12.3456789012	24.6913578024	4.115226300400
+123.4567890123	246.9135780246	41.152263004100
+123.4567890123	246.9135780246	41.152263004100
+123.4567890123	246.9135780246	41.152263004100
+1234.5678901235	2469.1357802470	411.522630041167
+1234.5678901235	2469.1357802470	411.522630041167
+1234.5678901235	2469.1357802470	411.522630041167
+12345.6789012346	24691.3578024692	4115.226300411533
+12345.6789012346	24691.3578024692	4115.226300411533
+123456.7890123456	246913.5780246912	41152.263004115200
+123456.7890123457	246913.5780246914	41152.263004115233
+1234567.8901234560	2469135.7802469120	411522.630041152000
+1234567.8901234568	2469135.7802469136	411522.630041152267
+12345678.9012345600	24691357.8024691200	4115226.300411520000
+12345678.9012345679	24691357.8024691358	4115226.300411522633
+123456789.0123456000	246913578.0246912000	41152263.004115200000
+123456789.0123456789	246913578.0246913578	41152263.004115226300
+1234567890.1234560000	2469135780.2469120000	411522630.041152000000
+1234567890.1234567890	2469135780.2469135780	411522630.041152263000
 PREHOOK: query: SELECT dec, dec / 9 FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision
@@ -348,37 +348,37 @@ NULL	NULL
 NULL	NULL
 NULL	NULL
 NULL	NULL
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.1234567890	0.013717421000000000
-0.1234567890	0.013717421000000000
-1.2345678901	0.137174210011111111
-1.2345678901	0.137174210011111111
-1.2345678901	0.137174210011111111
-12.3456789012	1.371742100133333333
-12.3456789012	1.371742100133333333
-12.3456789012	1.371742100133333333
-123.4567890123	13.717421001366666667
-123.4567890123	13.717421001366666667
-123.4567890123	13.717421001366666667
-1234.5678901235	137.174210013722222222
-1234.5678901235	137.174210013722222222
-1234.5678901235	137.174210013722222222
-12345.6789012346	1371.742100137177777778
-12345.6789012346	1371.742100137177777778
-123456.7890123456	13717.421001371733333333
-123456.7890123457	13717.421001371744444444
-1234567.8901234560	137174.210013717333333333
-1234567.8901234568	137174.210013717422222222
-12345678.9012345600	1371742.100137173333333333
-12345678.9012345679	1371742.100137174211111111
-123456789.0123456000	13717421.001371733333333333
-123456789.0123456789	13717421.001371742100000000
-1234567890.1234560000	137174210.013717333333333333
-1234567890.1234567890	137174210.013717421000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.0000000000	0.000000000000
+0.1234567890	0.013717421000
+0.1234567890	0.013717421000
+1.2345678901	0.137174210011
+1.2345678901	0.137174210011
+1.2345678901	0.137174210011
+12.3456789012	1.371742100133
+12.3456789012	1.371742100133
+12.3456789012	1.371742100133
+123.4567890123	13.717421001367
+123.4567890123	13.717421001367
+123.4567890123	13.717421001367
+1234.5678901235	137.174210013722
+1234.5678901235	137.174210013722
+1234.5678901235	137.174210013722
+12345.6789012346	1371.742100137178
+12345.6789012346	1371.742100137178
+123456.7890123456	13717.421001371733
+123456.7890123457	13717.421001371744
+1234567.8901234560	137174.210013717333
+1234567.8901234568	137174.210013717422
+12345678.9012345600	1371742.100137173333
+12345678.9012345679	1371742.100137174211
+123456789.0123456000	13717421.001371733333
+123456789.0123456789	13717421.001371742100
+1234567890.1234560000	137174210.013717333333
+1234567890.1234567890	137174210.013717421000
 PREHOOK: query: SELECT dec, dec / 27 FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision
@@ -431,37 +431,37 @@ NULL	NULL
 NULL	NULL
 NULL	NULL
 NULL	NULL
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.0000000000	0.000000000000000000
-0.1234567890	0.004572473666666667
-0.1234567890	0.004572473666666667
-1.2345678901	0.045724736670370370
-1.2345678901	0.045724736670370370
-1.2345678901	0.045724736670370370
-12.3456789012	0.457247366711111111
-12.3456789012	0.457247366711111111
-12.3456789012	0.457247366711111111
-123.4567890123	4.572473667122222222
-123.4567890123	4.572473667122222222
-123.4567890123	4.572473667122222222
-1234.5678901235	45.724736671240740741
-1234.5678901235	45.724736671240740741
-1234.5678901235	45.724736671240740741
-12345.6789012346	457.247366712392592593
-12345.6789012346	457.247366712392592593
-123456.7890123456	4572.473667123911111111
-123456.7890123457	4572.473667123914814815
-1234567.8901234560	45724.736671239111111111
-1234567.8901234568	45724.736671239140740741
-12345678.9012345600	457247.366712391111111111
-12345678.9012345679	457247.366712391403703704
-123456789.0123456000	4572473.667123911111111111
-123456789.0123456789	4572473.667123914033333333
-1234567890.1234560000	45724736.671239111111111111
-1234567890.1234567890	45724736.671239140333333333
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.0000000000	0.0000000000000
+0.1234567890	0.0045724736667
+0.1234567890	0.0045724736667
+1.2345678901	0.0457247366704
+1.2345678901	0.0457247366704
+1.2345678901	0.0457247366704
+12.3456789012	0.4572473667111
+12.3456789012	0.4572473667111
+12.3456789012	0.4572473667111
+123.4567890123	4.5724736671222
+123.4567890123	4.5724736671222
+123.4567890123	4.5724736671222
+1234.5678901235	45.7247366712407
+1234.5678901235	45.7247366712407
+1234.5678901235	45.7247366712407
+12345.6789012346	457.2473667123926
+12345.6789012346	457.2473667123926
+123456.7890123456	4572.4736671239111
+123456.7890123457	4572.4736671239148
+1234567.8901234560	45724.7366712391111
+1234567.8901234568	45724.7366712391407
+12345678.9012345600	457247.3667123911111
+12345678.9012345679	457247.3667123914037
+123456789.0123456000	4572473.6671239111111
+123456789.0123456789	4572473.6671239140333
+1234567890.1234560000	45724736.6712391111111
+1234567890.1234567890	45724736.6712391403333
 PREHOOK: query: SELECT dec, dec * dec FROM DECIMAL_PRECISION ORDER BY dec
 PREHOOK: type: QUERY
 PREHOOK: Input: default@decimal_precision

http://git-wip-us.apache.org/repos/asf/hive/blob/eb5dde21/ql/src/test/results/clientpositive/llap/vector_decimal_udf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/llap/vector_decimal_udf.q.out b/ql/src/test/results/clientpositive/llap/vector_decimal_udf.q.out
index 40dc99a..0813854 100644
--- a/ql/src/test/results/clientpositive/llap/vector_decimal_udf.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_decimal_udf.q.out
@@ -1155,7 +1155,7 @@ STAGE PLANS:
                   alias: decimal_udf
                   Statistics: Num rows: 38 Data size: 4296 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: (key / 0) (type: decimal(28,18))
+                    expressions: (key / 0) (type: decimal(22,12))
                     outputColumnNames: _col0
                     Statistics: Num rows: 38 Data size: 4296 Basic stats: COMPLETE Column stats: NONE
                     Limit
@@ -2259,7 +2259,7 @@ STAGE PLANS:
                   alias: decimal_udf
                   Statistics: Num rows: 38 Data size: 4296 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: ((key + 1) % (key / 2)) (type: decimal(28,18))
+                    expressions: ((key + 1) % (key / 2)) (type: decimal(22,12))
                     outputColumnNames: _col0
                     Statistics: Num rows: 38 Data size: 4296 Basic stats: COMPLETE Column stats: NONE
                     File Output Operator
@@ -2286,44 +2286,44 @@ POSTHOOK: query: SELECT (key + 1) % (key / 2) FROM DECIMAL_UDF
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@decimal_udf
 #### A masked pattern was here ####
--2199.000000000000000000
+-2199.000000000000
 NULL
 NULL
 NULL
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
-0.000000000000000000
-0.000000000000000000
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
+1.000000000000
+1.000000000000
+0.000000000000
+0.000000000000
+0.000000000000
+1.000000000000
+1.000000000000
+0.000000000000
 NULL
-0.000000000000000000
-0.000000000000000000
-0.100000000000000000
-0.010000000000000000
-0.001000000000000000
-0.100000000000000000
-0.010000000000000000
-0.001000000000000000
-0.000000000000000000
-0.000000000000000000
-1.000000000000000000
--0.120000000000000000
--0.120000000000000000
--0.122000000000000000
-0.440000000000000000
-0.439000000000000000
-1.000000000000000000
-1.000000000000000000
--626.745000000000000000
-1.000000000000000000
-1.000000000000000000
-1.000000000000000000
-0.000000000000000000
--617283944.061728394500000000
-1.000000000000000000
+0.000000000000
+0.000000000000
+0.100000000000
+0.010000000000
+0.001000000000
+0.100000000000
+0.010000000000
+0.001000000000
+0.000000000000
+0.000000000000
+1.000000000000
+-0.120000000000
+-0.120000000000
+-0.122000000000
+0.440000000000
+0.439000000000
+1.000000000000
+1.000000000000
+-626.745000000000
+1.000000000000
+1.000000000000
+1.000000000000
+0.000000000000
+-617283944.061728394500
+1.000000000000
 PREHOOK: query: -- stddev, var
 EXPLAIN SELECT value, stddev(key), variance(key) FROM DECIMAL_UDF GROUP BY value
 PREHOOK: type: QUERY