You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2019/06/08 04:32:08 UTC

[hive] branch master updated: HIVE-21742 : Vectorization: CASE result type casting (Vineet Garg via Gopal V)

This is an automated email from the ASF dual-hosted git repository.

hashutosh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 07b4b84  HIVE-21742 : Vectorization: CASE result type casting (Vineet Garg via Gopal V)
07b4b84 is described below

commit 07b4b8440b85002ef2fc16033bc676e2a2d83b81
Author: Vineet Garg <vg...@apache.org>
AuthorDate: Fri Jun 7 21:31:16 2019 -0700

    HIVE-21742 : Vectorization: CASE result type casting (Vineet Garg via Gopal V)
    
    Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
---
 .../rules/HiveExpandDistinctAggregatesRule.java    |   4 +-
 .../calcite/translator/RexNodeConverter.java       |  16 +-
 .../queries/clientpositive/vector_case_when_2.q    |  19 +-
 .../results/clientpositive/deleteAnalyze.q.out     |   6 +-
 .../druid/druidkafkamini_basic.q.out               |   2 +-
 .../results/clientpositive/infer_join_preds.q.out  |   4 +-
 .../clientpositive/llap/subquery_select.q.out      |  14 +-
 .../clientpositive/llap/vector_case_when_1.q.out   |  16 +-
 .../clientpositive/llap/vector_case_when_2.q.out   | 286 +++++++++++++++++++++
 .../clientpositive/llap/vector_coalesce.q.out      |   2 +-
 .../clientpositive/perf/spark/query40.q.out        |   8 +-
 .../clientpositive/perf/spark/query49.q.out        |  72 +++---
 .../clientpositive/perf/spark/query78.q.out        |   4 +-
 .../clientpositive/perf/spark/query80.q.out        |  30 +--
 .../clientpositive/perf/tez/cbo_query2.q.out       |   4 +-
 .../clientpositive/perf/tez/cbo_query39.q.out      |   4 +-
 .../clientpositive/perf/tez/cbo_query40.q.out      |   2 +-
 .../clientpositive/perf/tez/cbo_query43.q.out      |   2 +-
 .../clientpositive/perf/tez/cbo_query49.q.out      |  12 +-
 .../clientpositive/perf/tez/cbo_query59.q.out      |   4 +-
 .../clientpositive/perf/tez/cbo_query66.q.out      |   4 +-
 .../clientpositive/perf/tez/cbo_query77.q.out      |   4 +-
 .../clientpositive/perf/tez/cbo_query78.q.out      |   4 +-
 .../clientpositive/perf/tez/cbo_query80.q.out      |   6 +-
 .../perf/tez/constraints/cbo_query2.q.out          |   4 +-
 .../perf/tez/constraints/cbo_query39.q.out         |   4 +-
 .../perf/tez/constraints/cbo_query40.q.out         |   2 +-
 .../perf/tez/constraints/cbo_query43.q.out         |   2 +-
 .../perf/tez/constraints/cbo_query49.q.out         |   6 +-
 .../perf/tez/constraints/cbo_query59.q.out         |   4 +-
 .../perf/tez/constraints/cbo_query66.q.out         |   4 +-
 .../perf/tez/constraints/cbo_query77.q.out         |   4 +-
 .../perf/tez/constraints/cbo_query78.q.out         |   2 +-
 .../perf/tez/constraints/cbo_query80.q.out         |   6 +-
 .../perf/tez/constraints/mv_query67.q.out          |   2 +-
 ql/src/test/results/clientpositive/semijoin5.q.out |   2 +-
 .../clientpositive/spark/subquery_select.q.out     |  10 +-
 .../test/results/clientpositive/union_offcbo.q.out |   8 +-
 .../clientpositive/vector_case_when_1.q.out        |  16 +-
 .../clientpositive/vector_case_when_2.q.out        | 228 ++++++++++++++++
 .../results/clientpositive/vector_coalesce.q.out   |   2 +-
 41 files changed, 683 insertions(+), 152 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
index c7bb23d..103d5e1 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
@@ -250,8 +250,10 @@ public final class HiveExpandDistinctAggregatesRule extends RelOptRule {
             originalInputRefs.get(pos));
         condition = rexBuilder.makeCall(SqlStdOperatorTable.AND, condition, notNull);
       }
+      RexNode caseExpr1 = rexBuilder.makeExactLiteral(BigDecimal.ONE);
+      RexNode caseExpr2 = rexBuilder.makeNullLiteral(caseExpr1.getType());
       RexNode when = rexBuilder.makeCall(SqlStdOperatorTable.CASE, condition,
-          rexBuilder.makeExactLiteral(BigDecimal.ONE), rexBuilder.constantNull());
+          caseExpr1, caseExpr2);
       gbChildProjLst.add(when);
     }
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
index 89fad04..100ee0b 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java
@@ -571,22 +571,12 @@ public class RexNodeConverter {
    * If a CASE has branches with string/int/boolean branch types; there is no common type.
    */
   private List<RexNode> adjustCaseBranchTypes(List<RexNode> nodes, RelDataType retType) {
-    List<RelDataType> branchTypes = new ArrayList<>();
-    for (int i = 0; i < nodes.size(); i++) {
-      if (i % 2 == 1 || i == nodes.size() - 1) {
-        branchTypes.add(nodes.get(i).getType());
-      }
-    }
-    RelDataType commonType = cluster.getTypeFactory().leastRestrictive(branchTypes);
-    if (commonType != null) {
-      // conversion is possible; not changes are neccessary
-      return nodes;
-    }
     List<RexNode> newNodes = new ArrayList<>();
     for (int i = 0; i < nodes.size(); i++) {
       RexNode node = nodes.get(i);
-      if (i % 2 == 1 || i == nodes.size() - 1) {
-        newNodes.add(cluster.getRexBuilder().makeCast(retType, node));
+      if ((i % 2 == 1 || i == nodes.size() - 1)
+          && !node.getType().getSqlTypeName().equals(retType.getSqlTypeName())) {
+          newNodes.add(cluster.getRexBuilder().makeCast(retType, node));
       } else {
         newNodes.add(node);
       }
diff --git a/ql/src/test/queries/clientpositive/vector_case_when_2.q b/ql/src/test/queries/clientpositive/vector_case_when_2.q
index 6854fc0..4d0a340 100644
--- a/ql/src/test/queries/clientpositive/vector_case_when_2.q
+++ b/ql/src/test/queries/clientpositive/vector_case_when_2.q
@@ -205,4 +205,21 @@ SELECT
    IF(cast(ctimestamp1 as double) % 500 > 100, DATE_ADD(cdate, 1), DATE_ADD(cdate, 365)) AS Field_5
 FROM timestamps
 ORDER BY ctimestamp1, stimestamp1, ctimestamp2;
- 
\ No newline at end of file
+
+
+create temporary table foo(q548284 int);
+insert into foo values(1),(2),(3),(4),(5),(6);
+
+set hive.cbo.enable=true;
+explain vectorization detail select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1;
+select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1;
+
+explain vectorization detail select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8)
+    WHEN ((q548284 = 5)) THEN (1) ELSE (8) END from foo order by q548284 limit 1;
+select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END
+    from foo order by q548284 limit 1;
+
diff --git a/ql/src/test/results/clientpositive/deleteAnalyze.q.out b/ql/src/test/results/clientpositive/deleteAnalyze.q.out
index a26c04f..4de1f7b 100644
--- a/ql/src/test/results/clientpositive/deleteAnalyze.q.out
+++ b/ql/src/test/results/clientpositive/deleteAnalyze.q.out
@@ -195,7 +195,7 @@ STAGE PLANS:
               predicate: ((id = 2) and item is not null) (type: boolean)
               Statistics: Num rows: 1 Data size: 312 Basic stats: COMPLETE Column stats: COMPLETE
               Select Operator
-                expressions: item (type: string), CASE WHEN (amount is not null) THEN (amount) ELSE (0) END (type: decimal(13,3)), CASE WHEN (sales_tax is not null) THEN (sales_tax) ELSE (0) END (type: decimal(13,3))
+                expressions: item (type: string), CASE WHEN (amount is not null) THEN (amount) ELSE (0) END (type: decimal(10,3)), CASE WHEN (sales_tax is not null) THEN (sales_tax) ELSE (0) END (type: decimal(10,3))
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 1 Data size: 308 Basic stats: COMPLETE Column stats: COMPLETE
                 Reduce Output Operator
@@ -203,7 +203,7 @@ STAGE PLANS:
                   sort order: +
                   Map-reduce partition columns: _col0 (type: string)
                   Statistics: Num rows: 1 Data size: 308 Basic stats: COMPLETE Column stats: COMPLETE
-                  value expressions: _col1 (type: decimal(13,3)), _col2 (type: decimal(13,3))
+                  value expressions: _col1 (type: decimal(10,3)), _col2 (type: decimal(10,3))
       Reduce Operator Tree:
         Join Operator
           condition map:
@@ -214,7 +214,7 @@ STAGE PLANS:
           outputColumnNames: _col0, _col3, _col4
           Statistics: Num rows: 1 Data size: 228 Basic stats: COMPLETE Column stats: COMPLETE
           Select Operator
-            expressions: _col0 (type: int), _col3 (type: decimal(13,3)), _col4 (type: decimal(13,3))
+            expressions: _col0 (type: int), _col3 (type: decimal(10,3)), _col4 (type: decimal(10,3))
             outputColumnNames: _col0, _col1, _col2
             Statistics: Num rows: 1 Data size: 228 Basic stats: COMPLETE Column stats: COMPLETE
             File Output Operator
diff --git a/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out b/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
index 5301644..162b720 100644
--- a/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
+++ b/ql/src/test/results/clientpositive/druid/druidkafkamini_basic.q.out
@@ -652,7 +652,7 @@ STAGE PLANS:
           properties:
             druid.fieldNames language,a,b
             druid.fieldTypes string,double,decimal(19,0)
-            druid.query.json {"queryType":"groupBy","dataSource":"default.druid_kafka_test","granularity":"all","dimensions":[{"type":"default","dimension":"language","outputName":"language","outputType":"STRING"}],"limitSpec":{"type":"default","columns":[{"dimension":"a","direction":"descending","dimensionOrder":"numeric"}]},"aggregations":[{"type":"longSum","name":"$f1","fieldName":"added"},{"type":"longSum","name":"$f2","fieldName":"deleted"}],"postAggregations":[{"type":"expression", [...]
+            druid.query.json {"queryType":"groupBy","dataSource":"default.druid_kafka_test","granularity":"all","dimensions":[{"type":"default","dimension":"language","outputName":"language","outputType":"STRING"}],"limitSpec":{"type":"default","columns":[{"dimension":"a","direction":"descending","dimensionOrder":"numeric"}]},"aggregations":[{"type":"longSum","name":"$f1","fieldName":"added"},{"type":"longSum","name":"$f2","fieldName":"deleted"}],"postAggregations":[{"type":"expression", [...]
             druid.query.type groupBy
           Select Operator
             expressions: language (type: string), a (type: double), b (type: decimal(19,0))
diff --git a/ql/src/test/results/clientpositive/infer_join_preds.q.out b/ql/src/test/results/clientpositive/infer_join_preds.q.out
index 11dbfa1..9b8b038 100644
--- a/ql/src/test/results/clientpositive/infer_join_preds.q.out
+++ b/ql/src/test/results/clientpositive/infer_join_preds.q.out
@@ -1187,7 +1187,7 @@ STAGE PLANS:
               predicate: prid is not null (type: boolean)
               Statistics: Num rows: 1 Data size: 668 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: idp_warehouse_id (type: bigint), prid (type: bigint), concat(CAST( CASE WHEN (prid is null) THEN (1) ELSE (prid) END AS STRING), ',', CASE WHEN (prtimesheetid is null) THEN (1) ELSE (prtimesheetid) END, ',', CASE WHEN (prassignmentid is null) THEN (1) ELSE (prassignmentid) END, ',', CASE WHEN (prchargecodeid is null) THEN (1) ELSE (prchargecodeid) END, ',', CASE WHEN (prtypecodeid is null) THEN ('') ELSE (CAST( prtypecodeid AS STRING)) END, ',', CASE WHEN (pr [...]
+                expressions: idp_warehouse_id (type: bigint), prid (type: bigint), concat(CAST( CASE WHEN (prid is null) THEN (1L) ELSE (prid) END AS STRING), ',', CASE WHEN (prtimesheetid is null) THEN (1L) ELSE (prtimesheetid) END, ',', CASE WHEN (prassignmentid is null) THEN (1L) ELSE (prassignmentid) END, ',', CASE WHEN (prchargecodeid is null) THEN (1L) ELSE (prchargecodeid) END, ',', CASE WHEN (prtypecodeid is null) THEN ('') ELSE (CAST( prtypecodeid AS STRING)) END, ',', CASE WHEN [...]
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 1 Data size: 668 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
@@ -1246,7 +1246,7 @@ STAGE PLANS:
               predicate: prid is not null (type: boolean)
               Statistics: Num rows: 1 Data size: 776 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: prid (type: bigint), concat(CASE WHEN (length(pruid) is null) THEN ('') ELSE (pruid) END, ',', CASE WHEN (prid is null) THEN (1) ELSE (prid) END, ',', CASE WHEN (prtimesheetid is null) THEN (1) ELSE (prtimesheetid) END, ',', CASE WHEN (prassignmentid is null) THEN (1) ELSE (prassignmentid) END, ',', CASE WHEN (prchargecodeid is null) THEN (1) ELSE (prchargecodeid) END, ',', CASE WHEN (prtypecodeid is null) THEN ('') ELSE (CAST( prtypecodeid AS STRING)) END, ' [...]
+                expressions: prid (type: bigint), concat(CASE WHEN (length(pruid) is null) THEN ('') ELSE (pruid) END, ',', CASE WHEN (prid is null) THEN (1L) ELSE (prid) END, ',', CASE WHEN (prtimesheetid is null) THEN (1L) ELSE (prtimesheetid) END, ',', CASE WHEN (prassignmentid is null) THEN (1L) ELSE (prassignmentid) END, ',', CASE WHEN (prchargecodeid is null) THEN (1L) ELSE (prchargecodeid) END, ',', CASE WHEN (prtypecodeid is null) THEN ('') ELSE (CAST( prtypecodeid AS STRING)) EN [...]
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 1 Data size: 776 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
diff --git a/ql/src/test/results/clientpositive/llap/subquery_select.q.out b/ql/src/test/results/clientpositive/llap/subquery_select.q.out
index 7d6f226..8b4af96 100644
--- a/ql/src/test/results/clientpositive/llap/subquery_select.q.out
+++ b/ql/src/test/results/clientpositive/llap/subquery_select.q.out
@@ -3943,10 +3943,14 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0
                 Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
-                  value expressions: _col0 (type: int)
+                Select Operator
+                  expressions: UDFToDouble(_col0) (type: double)
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    sort order: 
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: double)
         Reducer 2 
             Execution mode: llap
             Reduce Operator Tree:
@@ -3987,7 +3991,7 @@ STAGE PLANS:
                   0 
                   1 
                 outputColumnNames: _col1, _col2, _col3
-                Statistics: Num rows: 26 Data size: 416 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 520 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
                   expressions: CASE WHEN (_col1) THEN (_col2) ELSE (_col3) END (type: double)
                   outputColumnNames: _col0
diff --git a/ql/src/test/results/clientpositive/llap/vector_case_when_1.q.out b/ql/src/test/results/clientpositive/llap/vector_case_when_1.q.out
index 5323159..db7140a 100644
--- a/ql/src/test/results/clientpositive/llap/vector_case_when_1.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_case_when_1.q.out
@@ -209,13 +209,13 @@ STAGE PLANS:
                       native: true
                       vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
                   Select Operator
-                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
+                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
                         projectedOutputColumnNums: [4, 21, 26, 30, 34, 38, 42, 44, 46, 48, 50, 52, 54, 58, 61, 64, 67]
-                        selectExpressions: VectorUDFAdaptor(CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, LongColLessLongScalar(col 4:int, val 100) -> 20:boolean) -> 21:stri [...]
+                        selectExpressions: VectorUDFAdaptor(CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, LongColLessLongScalar(col 4:int, val 100) -> 20:boolean) -> 21:stri [...]
                     Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
                       compressed: false
@@ -546,13 +546,13 @@ STAGE PLANS:
                       native: true
                       vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
                   Select Operator
-                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
+                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
-                        projectedOutputColumnNums: [4, 24, 33, 40, 44, 49, 53, 55, 57, 59, 61, 63, 65, 69, 72, 75, 78]
-                        selectExpressions: IfExprStringScalarStringGroupColumn(col 17:boolean, val Singlecol 23:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, IfExprStringScalarStringGroupColumn(col 18:boolean, val Twocol 22:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, IfExprStringScalarStringGroupColumn(col 19:boolean, val Somecol 21:string)(children: LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, IfExprStringScalarStringS [...]
+                        projectedOutputColumnNums: [4, 24, 33, 40, 44, 48, 52, 54, 56, 58, 60, 62, 64, 68, 71, 74, 77]
+                        selectExpressions: IfExprStringScalarStringGroupColumn(col 17:boolean, val Singlecol 23:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, IfExprStringScalarStringGroupColumn(col 18:boolean, val Twocol 22:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, IfExprStringScalarStringGroupColumn(col 19:boolean, val Somecol 21:string)(children: LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, IfExprStringScalarStringS [...]
                     Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
                       compressed: false
@@ -580,7 +580,7 @@ STAGE PLANS:
                     includeColumns: [1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14]
                     dataColumns: l_orderkey:int, l_partkey:int, l_suppkey:int, l_linenumber:int, l_quantity:int, l_extendedprice:double, l_discount:double, l_tax:decimal(10,2)/DECIMAL_64, l_returnflag:char(1), l_linestatus:char(1), l_shipdate:date, l_commitdate:date, l_receiptdate:date, l_shipinstruct:varchar(20), l_shipmode:char(10), l_comment:string
                     partitionColumnCount: 0
-                    scratchColumnTypeNames: [bigint, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, string, string, string, string, string, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, bigint, double, double, double, double, bigint, double, double, double, bigint, decimal(10,2), bigint, decimal(10,2), bigint, decimal(12,2), bigint, decimal(12,2), bigint, decimal(10,2)/DECIMAL_64, bigint, decimal(10,2)/DEC [...]
+                    scratchColumnTypeNames: [bigint, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, string, string, string, string, string, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, bigint, double, double, double, bigint, double, double, double, bigint, decimal(10,2), bigint, decimal(10,2), bigint, decimal(12,2), bigint, decimal(12,2), bigint, decimal(10,2)/DECIMAL_64, bigint, decimal(10,2)/DECIMAL_64, [...]
 
   Stage: Stage-0
     Fetch Operator
@@ -883,13 +883,13 @@ STAGE PLANS:
                       native: true
                       vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
                   Select Operator
-                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
+                    expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Sing [...]
                     outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
                     Select Vectorization:
                         className: VectorSelectOperator
                         native: true
                         projectedOutputColumnNums: [4, 27, 39, 48, 52, 57, 62, 64, 66, 71, 76, 78, 80, 84, 87, 90, 93]
-                        selectExpressions: IfExprColumnCondExpr(col 17:boolean, col 18:stringcol 26:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, ConstantVectorExpression(val Single) -> 18:string, IfExprColumnCondExpr(col 19:boolean, col 20:stringcol 25:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 19:boolean, ConstantVectorExpression(val Two) -> 20:string, IfExprColumnCondExpr(col 21:boolean, col 22:stringcol 24:string)(children: LongColLessLo [...]
+                        selectExpressions: IfExprColumnCondExpr(col 17:boolean, col 18:stringcol 26:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, ConstantVectorExpression(val Single) -> 18:string, IfExprColumnCondExpr(col 19:boolean, col 20:stringcol 25:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 19:boolean, ConstantVectorExpression(val Two) -> 20:string, IfExprColumnCondExpr(col 21:boolean, col 22:stringcol 24:string)(children: LongColLessLo [...]
                     Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
                     File Output Operator
                       compressed: false
diff --git a/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out b/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
index d7a7c2f..38ba5f9 100644
--- a/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_case_when_2.q.out
@@ -917,3 +917,289 @@ ctimestamp1	ctimestamp2	ctimestamp2_description	ctimestamp2_description_2	ctimes
 9209-11-11 04:08:58.223768453	9209-11-10 02:05:54.223768453	Unknown	NULL	NULL	9209	2018-03-08 23:04:59	8	NULL	9209-11-12
 9403-01-09 18:12:33.547	9403-01-08 16:09:29.547	Unknown	NULL	NULL	9403	2018-03-08 23:04:59	12	NULL	9404-01-09
 NULL	NULL	Unknown	NULL	NULL	NULL	2018-03-08 23:04:59	NULL	NULL	NULL
+PREHOOK: query: create temporary table foo(q548284 int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@foo
+POSTHOOK: query: create temporary table foo(q548284 int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@foo
+PREHOOK: query: insert into foo values(1),(2),(3),(4),(5),(6)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@foo
+POSTHOOK: query: insert into foo values(1),(2),(3),(4),(5),(6)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@foo
+POSTHOOK: Lineage: foo.q548284 SCRIPT []
+col1
+PREHOOK: query: explain vectorization detail select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: explain vectorization detail select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+Explain
+PLAN VECTORIZATION:
+  enabled: true
+  enabledConditionsMet: [hive.vectorized.execution.enabled IS true]
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: foo
+                  Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                  TableScan Vectorization:
+                      native: true
+                      vectorizationSchemaColumns: [0:q548284:int, 1:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
+                  Select Operator
+                    expressions: q548284 (type: int), CASE WHEN ((q548284 = 1)) THEN (0.2) WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END (type: decimal(11,1))
+                    outputColumnNames: _col0, _col1
+                    Select Vectorization:
+                        className: VectorSelectOperator
+                        native: true
+                        projectedOutputColumnNums: [0, 16]
+                        selectExpressions: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(11,1)col 15:decimal(11,1))(children: LongColEqualLongScalar(col 0:int, val 1) -> 2:boolean, ConstantVectorExpression(val 0.2) -> 3:decimal(11,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(11,1)col 14:decimal(11,1))(children: LongColEqualLongScalar(col 0:int, val 2) -> 4:boolean, ConstantVectorExpression(val 0.4) -> 5:decimal(11,1), IfExprCondExprCondExpr(col 6:boolean, col 7:decimal(1 [...]
+                    Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int)
+                      sort order: +
+                      Reduce Sink Vectorization:
+                          className: VectorReduceSinkObjectHashOperator
+                          keyColumns: 0:int
+                          native: true
+                          nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                          valueColumns: 16:decimal(11,1)
+                      Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                      TopN Hash Memory Usage: 0.1
+                      value expressions: _col1 (type: decimal(11,1))
+            Execution mode: vectorized, llap
+            LLAP IO: no inputs
+            Map Vectorization:
+                enabled: true
+                enabledConditionsMet: hive.vectorized.use.vector.serde.deserialize IS true
+                inputFormatFeatureSupport: [DECIMAL_64]
+                featureSupportInUse: [DECIMAL_64]
+                inputFileFormats: org.apache.hadoop.mapred.TextInputFormat
+                allNative: true
+                usesVectorUDFAdaptor: false
+                vectorized: true
+                rowBatchContext:
+                    dataColumnCount: 1
+                    includeColumns: [0]
+                    dataColumns: q548284:int
+                    partitionColumnCount: 0
+                    scratchColumnTypeNames: [bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1)]
+        Reducer 2 
+            Execution mode: vectorized, llap
+            Reduce Vectorization:
+                enabled: true
+                enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
+                reduceColumnNullOrder: z
+                reduceColumnSortOrder: +
+                allNative: false
+                usesVectorUDFAdaptor: false
+                vectorized: true
+                rowBatchContext:
+                    dataColumnCount: 2
+                    dataColumns: KEY.reducesinkkey0:int, VALUE._col0:decimal(11,1)
+                    partitionColumnCount: 0
+                    scratchColumnTypeNames: []
+            Reduce Operator Tree:
+              Select Operator
+                expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(11,1))
+                outputColumnNames: _col0, _col1
+                Select Vectorization:
+                    className: VectorSelectOperator
+                    native: true
+                    projectedOutputColumnNums: [0, 1]
+                Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                Limit
+                  Number of rows: 1
+                  Limit Vectorization:
+                      className: VectorLimitOperator
+                      native: true
+                  Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+                  File Output Operator
+                    compressed: false
+                    File Sink Vectorization:
+                        className: VectorFileSinkOperator
+                        native: false
+                    Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+q548284	_c1
+1	0.2
+PREHOOK: query: explain vectorization detail select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8)
+    WHEN ((q548284 = 5)) THEN (1) ELSE (8) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: explain vectorization detail select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8)
+    WHEN ((q548284 = 5)) THEN (1) ELSE (8) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+Explain
+PLAN VECTORIZATION:
+  enabled: true
+  enabledConditionsMet: [hive.vectorized.execution.enabled IS true]
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: foo
+                  Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                  TableScan Vectorization:
+                      native: true
+                      vectorizationSchemaColumns: [0:q548284:int, 1:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
+                  Select Operator
+                    expressions: q548284 (type: int), CASE WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END (type: decimal(2,1))
+                    outputColumnNames: _col0, _col1
+                    Select Vectorization:
+                        className: VectorSelectOperator
+                        native: true
+                        projectedOutputColumnNums: [0, 8]
+                        selectExpressions: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(2,1)col 7:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 4) -> 2:boolean, ConstantVectorExpression(val 0.8) -> 3:decimal(2,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(2,1)col 6:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 5) -> 4:boolean, ConstantVectorExpression(val 1) -> 5:decimal(2,1), ConstantVectorExpression(val 8) -> 6:decimal(2,1)) -> 7:decimal [...]
+                    Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int)
+                      sort order: +
+                      Reduce Sink Vectorization:
+                          className: VectorReduceSinkObjectHashOperator
+                          keyColumns: 0:int
+                          native: true
+                          nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                          valueColumns: 8:decimal(2,1)
+                      Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                      TopN Hash Memory Usage: 0.1
+                      value expressions: _col1 (type: decimal(2,1))
+            Execution mode: vectorized, llap
+            LLAP IO: no inputs
+            Map Vectorization:
+                enabled: true
+                enabledConditionsMet: hive.vectorized.use.vector.serde.deserialize IS true
+                inputFormatFeatureSupport: [DECIMAL_64]
+                featureSupportInUse: [DECIMAL_64]
+                inputFileFormats: org.apache.hadoop.mapred.TextInputFormat
+                allNative: true
+                usesVectorUDFAdaptor: false
+                vectorized: true
+                rowBatchContext:
+                    dataColumnCount: 1
+                    includeColumns: [0]
+                    dataColumns: q548284:int
+                    partitionColumnCount: 0
+                    scratchColumnTypeNames: [bigint, decimal(2,1), bigint, decimal(2,1), decimal(2,1), decimal(2,1), decimal(2,1)]
+        Reducer 2 
+            Execution mode: vectorized, llap
+            Reduce Vectorization:
+                enabled: true
+                enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true, hive.execution.engine tez IN [tez, spark] IS true
+                reduceColumnNullOrder: z
+                reduceColumnSortOrder: +
+                allNative: false
+                usesVectorUDFAdaptor: false
+                vectorized: true
+                rowBatchContext:
+                    dataColumnCount: 2
+                    dataColumns: KEY.reducesinkkey0:int, VALUE._col0:decimal(2,1)
+                    partitionColumnCount: 0
+                    scratchColumnTypeNames: []
+            Reduce Operator Tree:
+              Select Operator
+                expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(2,1))
+                outputColumnNames: _col0, _col1
+                Select Vectorization:
+                    className: VectorSelectOperator
+                    native: true
+                    projectedOutputColumnNums: [0, 1]
+                Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                Limit
+                  Number of rows: 1
+                  Limit Vectorization:
+                      className: VectorLimitOperator
+                      native: true
+                  Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+                  File Output Operator
+                    compressed: false
+                    File Sink Vectorization:
+                        className: VectorFileSinkOperator
+                        native: false
+                    Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+                    table:
+                        input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END
+    from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END
+    from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+q548284	_c1
+1	8.0
diff --git a/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out b/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
index 39c041c..3d70e15 100644
--- a/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_coalesce.q.out
@@ -152,7 +152,7 @@ STAGE PLANS:
                           className: VectorSelectOperator
                           native: true
                           projectedOutputColumnNums: [5, 2, 20]
-                          selectExpressions: IfExprCondExprCondExpr(col 16:boolean, col 18:doublecol 19:double)(children: ColAndCol(col 13:boolean, col 15:boolean)(children: IsNotNull(col 5:double) -> 13:boolean, IsNotNull(col 14:double)(children: FuncLog2LongToDouble(col 2:int) -> 14:double) -> 15:boolean) -> 16:boolean, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: FuncLog2LongToDouble(col 2:int) -> 17:double) -> 18:double, ConstantVectorExpression(val 0.0) -> 19:doub [...]
+                          selectExpressions: IfExprCondExprColumn(col 16:boolean, col 18:double, col 19:double)(children: ColAndCol(col 13:boolean, col 15:boolean)(children: IsNotNull(col 5:double) -> 13:boolean, IsNotNull(col 14:double)(children: FuncLog2LongToDouble(col 2:int) -> 14:double) -> 15:boolean) -> 16:boolean, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: FuncLog2LongToDouble(col 2:int) -> 17:double) -> 18:double, ConstantVectorExpression(val 0.0) -> 19:doub [...]
                         Reduce Sink Vectorization:
                             className: VectorReduceSinkObjectHashOperator
                             native: true
diff --git a/ql/src/test/results/clientpositive/perf/spark/query40.q.out b/ql/src/test/results/clientpositive/perf/spark/query40.q.out
index 01b8ed1..8930fcb 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query40.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query40.q.out
@@ -233,7 +233,7 @@ STAGE PLANS:
                       1 Map 9
                     Statistics: Num rows: 421645953 Data size: 57099332415 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: _col14 (type: string), _col9 (type: string), CASE WHEN (_col11) THEN ((_col4 - CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0) END)) ELSE (0) END (type: decimal(13,2)), CASE WHEN (_col12) THEN ((_col4 - CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0) END)) ELSE (0) END (type: decimal(13,2))
+                      expressions: _col14 (type: string), _col9 (type: string), CASE WHEN (_col11) THEN ((_col4 - CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0) END)) ELSE (0) END (type: decimal(8,2)), CASE WHEN (_col12) THEN ((_col4 - CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0) END)) ELSE (0) END (type: decimal(8,2))
                       outputColumnNames: _col0, _col1, _col2, _col3
                       Statistics: Num rows: 421645953 Data size: 57099332415 Basic stats: COMPLETE Column stats: NONE
                       Group By Operator
@@ -249,7 +249,7 @@ STAGE PLANS:
                           Map-reduce partition columns: _col0 (type: string), _col1 (type: string)
                           Statistics: Num rows: 421645953 Data size: 57099332415 Basic stats: COMPLETE Column stats: NONE
                           TopN Hash Memory Usage: 0.1
-                          value expressions: _col2 (type: decimal(23,2)), _col3 (type: decimal(23,2))
+                          value expressions: _col2 (type: decimal(18,2)), _col3 (type: decimal(18,2))
         Reducer 4 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -264,12 +264,12 @@ STAGE PLANS:
                   sort order: ++
                   Statistics: Num rows: 210822976 Data size: 28549666139 Basic stats: COMPLETE Column stats: NONE
                   TopN Hash Memory Usage: 0.1
-                  value expressions: _col2 (type: decimal(23,2)), _col3 (type: decimal(23,2))
+                  value expressions: _col2 (type: decimal(18,2)), _col3 (type: decimal(18,2))
         Reducer 5 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string), VALUE._col0 (type: decimal(23,2)), VALUE._col1 (type: decimal(23,2))
+                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string), VALUE._col0 (type: decimal(18,2)), VALUE._col1 (type: decimal(18,2))
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 210822976 Data size: 28549666139 Basic stats: COMPLETE Column stats: NONE
                 Limit
diff --git a/ql/src/test/results/clientpositive/perf/spark/query49.q.out b/ql/src/test/results/clientpositive/perf/spark/query49.q.out
index 119e84f..69dd18e 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query49.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query49.q.out
@@ -304,7 +304,7 @@ STAGE PLANS:
                     predicate: ((ws_net_paid > 0) and (ws_net_profit > 1) and (ws_quantity > 0) and ws_item_sk is not null and ws_order_number is not null and ws_sold_date_sk is not null) (type: boolean)
                     Statistics: Num rows: 5333432 Data size: 725192506 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: ws_sold_date_sk (type: int), ws_item_sk (type: int), ws_order_number (type: int), CASE WHEN (ws_quantity is not null) THEN (ws_quantity) ELSE (0) END (type: int), CASE WHEN (ws_net_paid is not null) THEN (ws_net_paid) ELSE (0) END (type: decimal(12,2))
+                      expressions: ws_sold_date_sk (type: int), ws_item_sk (type: int), ws_order_number (type: int), CASE WHEN (ws_quantity is not null) THEN (ws_quantity) ELSE (0) END (type: int), CASE WHEN (ws_net_paid is not null) THEN (ws_net_paid) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3, _col4
                       Statistics: Num rows: 5333432 Data size: 725192506 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -312,7 +312,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: int)
                         Statistics: Num rows: 5333432 Data size: 725192506 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(12,2))
+                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(7,2))
             Execution mode: vectorized
         Map 10 
             Map Operator Tree:
@@ -343,7 +343,7 @@ STAGE PLANS:
                     predicate: ((wr_return_amt > 10000) and wr_item_sk is not null and wr_order_number is not null) (type: boolean)
                     Statistics: Num rows: 4799489 Data size: 441731394 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: wr_item_sk (type: int), wr_order_number (type: int), CASE WHEN (wr_return_quantity is not null) THEN (wr_return_quantity) ELSE (0) END (type: int), CASE WHEN (wr_return_amt is not null) THEN (wr_return_amt) ELSE (0) END (type: decimal(12,2))
+                      expressions: wr_item_sk (type: int), wr_order_number (type: int), CASE WHEN (wr_return_quantity is not null) THEN (wr_return_quantity) ELSE (0) END (type: int), CASE WHEN (wr_return_amt is not null) THEN (wr_return_amt) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3
                       Statistics: Num rows: 4799489 Data size: 441731394 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -351,7 +351,7 @@ STAGE PLANS:
                         sort order: ++
                         Map-reduce partition columns: _col0 (type: int), _col1 (type: int)
                         Statistics: Num rows: 4799489 Data size: 441731394 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col2 (type: int), _col3 (type: decimal(12,2))
+                        value expressions: _col2 (type: int), _col3 (type: decimal(7,2))
             Execution mode: vectorized
         Map 12 
             Map Operator Tree:
@@ -363,7 +363,7 @@ STAGE PLANS:
                     predicate: ((cs_net_paid > 0) and (cs_net_profit > 1) and (cs_quantity > 0) and cs_item_sk is not null and cs_order_number is not null and cs_sold_date_sk is not null) (type: boolean)
                     Statistics: Num rows: 10666290 Data size: 1444429931 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: cs_sold_date_sk (type: int), cs_item_sk (type: int), cs_order_number (type: int), CASE WHEN (cs_quantity is not null) THEN (cs_quantity) ELSE (0) END (type: int), CASE WHEN (cs_net_paid is not null) THEN (cs_net_paid) ELSE (0) END (type: decimal(12,2))
+                      expressions: cs_sold_date_sk (type: int), cs_item_sk (type: int), cs_order_number (type: int), CASE WHEN (cs_quantity is not null) THEN (cs_quantity) ELSE (0) END (type: int), CASE WHEN (cs_net_paid is not null) THEN (cs_net_paid) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3, _col4
                       Statistics: Num rows: 10666290 Data size: 1444429931 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -371,7 +371,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: int)
                         Statistics: Num rows: 10666290 Data size: 1444429931 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(12,2))
+                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(7,2))
             Execution mode: vectorized
         Map 19 
             Map Operator Tree:
@@ -383,7 +383,7 @@ STAGE PLANS:
                     predicate: ((cr_return_amount > 10000) and cr_item_sk is not null and cr_order_number is not null) (type: boolean)
                     Statistics: Num rows: 9599627 Data size: 1019078226 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: cr_item_sk (type: int), cr_order_number (type: int), CASE WHEN (cr_return_quantity is not null) THEN (cr_return_quantity) ELSE (0) END (type: int), CASE WHEN (cr_return_amount is not null) THEN (cr_return_amount) ELSE (0) END (type: decimal(12,2))
+                      expressions: cr_item_sk (type: int), cr_order_number (type: int), CASE WHEN (cr_return_quantity is not null) THEN (cr_return_quantity) ELSE (0) END (type: int), CASE WHEN (cr_return_amount is not null) THEN (cr_return_amount) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3
                       Statistics: Num rows: 9599627 Data size: 1019078226 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -391,7 +391,7 @@ STAGE PLANS:
                         sort order: ++
                         Map-reduce partition columns: _col0 (type: int), _col1 (type: int)
                         Statistics: Num rows: 9599627 Data size: 1019078226 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col2 (type: int), _col3 (type: decimal(12,2))
+                        value expressions: _col2 (type: int), _col3 (type: decimal(7,2))
             Execution mode: vectorized
         Map 20 
             Map Operator Tree:
@@ -403,7 +403,7 @@ STAGE PLANS:
                     predicate: ((ss_net_paid > 0) and (ss_net_profit > 1) and (ss_quantity > 0) and ss_item_sk is not null and ss_sold_date_sk is not null and ss_ticket_number is not null) (type: boolean)
                     Statistics: Num rows: 21333171 Data size: 1882018537 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: ss_sold_date_sk (type: int), ss_item_sk (type: int), ss_ticket_number (type: int), CASE WHEN (ss_quantity is not null) THEN (ss_quantity) ELSE (0) END (type: int), CASE WHEN (ss_net_paid is not null) THEN (ss_net_paid) ELSE (0) END (type: decimal(12,2))
+                      expressions: ss_sold_date_sk (type: int), ss_item_sk (type: int), ss_ticket_number (type: int), CASE WHEN (ss_quantity is not null) THEN (ss_quantity) ELSE (0) END (type: int), CASE WHEN (ss_net_paid is not null) THEN (ss_net_paid) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3, _col4
                       Statistics: Num rows: 21333171 Data size: 1882018537 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -411,7 +411,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: int)
                         Statistics: Num rows: 21333171 Data size: 1882018537 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(12,2))
+                        value expressions: _col1 (type: int), _col2 (type: int), _col3 (type: int), _col4 (type: decimal(7,2))
             Execution mode: vectorized
         Map 27 
             Map Operator Tree:
@@ -423,7 +423,7 @@ STAGE PLANS:
                     predicate: ((sr_return_amt > 10000) and sr_item_sk is not null and sr_ticket_number is not null) (type: boolean)
                     Statistics: Num rows: 19197050 Data size: 1487398277 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: sr_item_sk (type: int), sr_ticket_number (type: int), CASE WHEN (sr_return_quantity is not null) THEN (sr_return_quantity) ELSE (0) END (type: int), CASE WHEN (sr_return_amt is not null) THEN (sr_return_amt) ELSE (0) END (type: decimal(12,2))
+                      expressions: sr_item_sk (type: int), sr_ticket_number (type: int), CASE WHEN (sr_return_quantity is not null) THEN (sr_return_quantity) ELSE (0) END (type: int), CASE WHEN (sr_return_amt is not null) THEN (sr_return_amt) ELSE (0) END (type: decimal(7,2))
                       outputColumnNames: _col0, _col1, _col2, _col3
                       Statistics: Num rows: 19197050 Data size: 1487398277 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -431,7 +431,7 @@ STAGE PLANS:
                         sort order: ++
                         Map-reduce partition columns: _col0 (type: int), _col1 (type: int)
                         Statistics: Num rows: 19197050 Data size: 1487398277 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col2 (type: int), _col3 (type: decimal(12,2))
+                        value expressions: _col2 (type: int), _col3 (type: decimal(7,2))
             Execution mode: vectorized
         Reducer 13 
             Reduce Operator Tree:
@@ -448,7 +448,7 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: _col1 (type: int), _col2 (type: int)
                   Statistics: Num rows: 11732919 Data size: 1588872958 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col3 (type: int), _col4 (type: decimal(12,2))
+                  value expressions: _col3 (type: int), _col4 (type: decimal(7,2))
         Reducer 14 
             Reduce Operator Tree:
               Join Operator
@@ -471,7 +471,7 @@ STAGE PLANS:
                     sort order: +
                     Map-reduce partition columns: _col0 (type: int)
                     Statistics: Num rows: 12906211 Data size: 1747760291 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 15 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -486,19 +486,19 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: 0 (type: int)
                   Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 16 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(22,2)), VALUE._col4 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(17,2)), VALUE._col4 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4
                 Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
                   Function definitions:
                       Input definition
                         input alias: ptf_0
-                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(22,2), _col4: decimal(22,2)
+                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(17,2), _col4: decimal(17,2)
                         type: WINDOWING
                       Windowing table definition
                         input alias: ptf_1
@@ -516,7 +516,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
                     outputColumnNames: rank_window_0, _col0, _col1, _col2, _col3, _col4
                     Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
@@ -524,12 +524,12 @@ STAGE PLANS:
                       sort order: ++
                       Map-reduce partition columns: 0 (type: int)
                       Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 17 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(22,2)), VALUE._col5 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(17,2)), VALUE._col5 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                 Statistics: Num rows: 6453105 Data size: 873880077 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
@@ -585,7 +585,7 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: _col1 (type: int), _col2 (type: int)
                   Statistics: Num rows: 5866775 Data size: 797711773 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col3 (type: int), _col4 (type: decimal(12,2))
+                  value expressions: _col3 (type: int), _col4 (type: decimal(7,2))
         Reducer 21 
             Reduce Operator Tree:
               Join Operator
@@ -601,7 +601,7 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: _col1 (type: int), _col2 (type: int)
                   Statistics: Num rows: 23466488 Data size: 2070220435 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col3 (type: int), _col4 (type: decimal(12,2))
+                  value expressions: _col3 (type: int), _col4 (type: decimal(7,2))
         Reducer 22 
             Reduce Operator Tree:
               Join Operator
@@ -624,7 +624,7 @@ STAGE PLANS:
                     sort order: +
                     Map-reduce partition columns: _col0 (type: int)
                     Statistics: Num rows: 25813137 Data size: 2277242527 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 23 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -639,19 +639,19 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: 0 (type: int)
                   Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 24 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(22,2)), VALUE._col4 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(17,2)), VALUE._col4 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4
                 Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
                   Function definitions:
                       Input definition
                         input alias: ptf_0
-                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(22,2), _col4: decimal(22,2)
+                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(17,2), _col4: decimal(17,2)
                         type: WINDOWING
                       Windowing table definition
                         input alias: ptf_1
@@ -669,7 +669,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
                     outputColumnNames: rank_window_0, _col0, _col1, _col2, _col3, _col4
                     Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
@@ -677,12 +677,12 @@ STAGE PLANS:
                       sort order: ++
                       Map-reduce partition columns: 0 (type: int)
                       Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 25 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(22,2)), VALUE._col5 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(17,2)), VALUE._col5 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                 Statistics: Num rows: 12906568 Data size: 1138621219 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
@@ -746,7 +746,7 @@ STAGE PLANS:
                     sort order: +
                     Map-reduce partition columns: _col0 (type: int)
                     Statistics: Num rows: 6453452 Data size: 877482969 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    value expressions: _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 4 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -761,19 +761,19 @@ STAGE PLANS:
                   sort order: ++
                   Map-reduce partition columns: 0 (type: int)
                   Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                  value expressions: _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 5 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(22,2)), VALUE._col4 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: decimal(17,2)), VALUE._col4 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4
                 Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
                   Function definitions:
                       Input definition
                         input alias: ptf_0
-                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(22,2), _col4: decimal(22,2)
+                        output shape: _col0: int, _col1: bigint, _col2: bigint, _col3: decimal(17,2), _col4: decimal(17,2)
                         type: WINDOWING
                       Windowing table definition
                         input alias: ptf_1
@@ -791,7 +791,7 @@ STAGE PLANS:
                               isPivotResult: true
                   Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                    expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
                     outputColumnNames: rank_window_0, _col0, _col1, _col2, _col3, _col4
                     Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
@@ -799,12 +799,12 @@ STAGE PLANS:
                       sort order: ++
                       Map-reduce partition columns: 0 (type: int)
                       Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(22,2)), _col4 (type: decimal(22,2))
+                      value expressions: rank_window_0 (type: int), _col0 (type: int), _col1 (type: bigint), _col2 (type: bigint), _col3 (type: decimal(17,2)), _col4 (type: decimal(17,2))
         Reducer 6 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(22,2)), VALUE._col5 (type: decimal(22,2))
+                expressions: VALUE._col0 (type: int), VALUE._col1 (type: int), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint), VALUE._col4 (type: decimal(17,2)), VALUE._col5 (type: decimal(17,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                 Statistics: Num rows: 3226726 Data size: 438741484 Basic stats: COMPLETE Column stats: NONE
                 PTF Operator
diff --git a/ql/src/test/results/clientpositive/perf/spark/query78.q.out b/ql/src/test/results/clientpositive/perf/spark/query78.q.out
index ca30d38..3aecec2 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query78.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query78.q.out
@@ -455,7 +455,7 @@ STAGE PLANS:
                     predicate: (_col2 > 0L) (type: boolean)
                     Statistics: Num rows: 29038976 Data size: 3932460694 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: _col1 (type: int), _col2 (type: bigint), _col2 is not null (type: boolean), CASE WHEN (_col2 is not null) THEN (_col2) ELSE (0) END (type: bigint), CASE WHEN (_col3 is not null) THEN (_col3) ELSE (0) END (type: decimal(17,2)), CASE WHEN (_col4 is not null) THEN (_col4) ELSE (0) END (type: decimal(17,2))
+                      expressions: _col1 (type: int), _col2 (type: bigint), _col2 is not null (type: boolean), CASE WHEN (_col2 is not null) THEN (_col2) ELSE (0L) END (type: bigint), CASE WHEN (_col3 is not null) THEN (_col3) ELSE (0) END (type: decimal(17,2)), CASE WHEN (_col4 is not null) THEN (_col4) ELSE (0) END (type: decimal(17,2))
                       outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                       Statistics: Num rows: 29038976 Data size: 3932460694 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
@@ -556,7 +556,7 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col7, _col8, _col9, _col11, _col12, _col13, _col14, _col15
                 Statistics: Num rows: 210828819 Data size: 18599379737 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: _col0 (type: int), _col1 (type: int), round((UDFToDouble(_col2) / UDFToDouble(CASE WHEN ((_col12 and _col7 is not null)) THEN ((_col7 + _col11)) ELSE (1) END)), 2) (type: double), (CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0) END + _col13) (type: bigint), (CASE WHEN (_col8 is not null) THEN (_col8) ELSE (0) END + _col14) (type: decimal(18,2)), (CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END + _col15) (type: decimal(18,2)), _col2 (type: bigin [...]
+                  expressions: _col0 (type: int), _col1 (type: int), round((UDFToDouble(_col2) / UDFToDouble(CASE WHEN ((_col12 and _col7 is not null)) THEN ((_col7 + _col11)) ELSE (1L) END)), 2) (type: double), (CASE WHEN (_col7 is not null) THEN (_col7) ELSE (0L) END + _col13) (type: bigint), (CASE WHEN (_col8 is not null) THEN (_col8) ELSE (0) END + _col14) (type: decimal(18,2)), (CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END + _col15) (type: decimal(18,2)), _col2 (type: big [...]
                   outputColumnNames: _col0, _col1, _col2, _col6, _col7, _col8, _col9, _col10, _col11, _col12
                   Statistics: Num rows: 210828819 Data size: 18599379737 Basic stats: COMPLETE Column stats: NONE
                   Reduce Output Operator
diff --git a/ql/src/test/results/clientpositive/perf/spark/query80.q.out b/ql/src/test/results/clientpositive/perf/spark/query80.q.out
index 7ab9894..2340493 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query80.q.out
@@ -656,7 +656,7 @@ STAGE PLANS:
                 outputColumnNames: _col5, _col6, _col9, _col10, _col15
                 Statistics: Num rows: 463810558 Data size: 62809267017 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(12,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(13,2))
+                  expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(7,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(8,2))
                   outputColumnNames: _col0, _col1, _col2, _col3
                   Statistics: Num rows: 463810558 Data size: 62809267017 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
@@ -671,7 +671,7 @@ STAGE PLANS:
                       sort order: +
                       Map-reduce partition columns: _col0 (type: string)
                       Statistics: Num rows: 463810558 Data size: 62809267017 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                      value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
         Reducer 18 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -682,7 +682,7 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 231905279 Data size: 31404633508 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: 'catalog channel' (type: string), concat('catalog_page', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                  expressions: 'catalog channel' (type: string), concat('catalog_page', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4
                   Statistics: Num rows: 231905279 Data size: 31404633508 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
@@ -698,7 +698,7 @@ STAGE PLANS:
                       Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
                       Statistics: Num rows: 2435062716 Data size: 264270971781 Basic stats: COMPLETE Column stats: NONE
                       TopN Hash Memory Usage: 0.1
-                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(32,2)), _col5 (type: decimal(33,2))
+                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(27,2)), _col5 (type: decimal(28,2))
         Reducer 2 
             Reduce Operator Tree:
               Join Operator
@@ -782,7 +782,7 @@ STAGE PLANS:
                     1 Map 33
                   Statistics: Num rows: 231917759 Data size: 31534108438 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(12,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(13,2))
+                    expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(7,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(8,2))
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 231917759 Data size: 31534108438 Basic stats: COMPLETE Column stats: NONE
                     Group By Operator
@@ -797,7 +797,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: string)
                         Statistics: Num rows: 231917759 Data size: 31534108438 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                        value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
         Reducer 28 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -808,7 +808,7 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 115958879 Data size: 15767054151 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: 'web channel' (type: string), concat('web_site', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                  expressions: 'web channel' (type: string), concat('web_site', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4
                   Statistics: Num rows: 115958879 Data size: 15767054151 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
@@ -824,7 +824,7 @@ STAGE PLANS:
                       Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
                       Statistics: Num rows: 2435062716 Data size: 264270971781 Basic stats: COMPLETE Column stats: NONE
                       TopN Hash Memory Usage: 0.1
-                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(32,2)), _col5 (type: decimal(33,2))
+                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(27,2)), _col5 (type: decimal(28,2))
         Reducer 3 
             Local Work:
               Map Reduce Local Work
@@ -876,7 +876,7 @@ STAGE PLANS:
                     1 Map 12
                   Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
                   Select Operator
-                    expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(12,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(13,2))
+                    expressions: _col15 (type: string), _col5 (type: decimal(7,2)), CASE WHEN (_col9 is not null) THEN (_col9) ELSE (0) END (type: decimal(7,2)), (_col6 - CASE WHEN (_col10 is not null) THEN (_col10) ELSE (0) END) (type: decimal(8,2))
                     outputColumnNames: _col0, _col1, _col2, _col3
                     Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
                     Group By Operator
@@ -891,7 +891,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: string)
                         Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                        value expressions: _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
         Reducer 5 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -902,7 +902,7 @@ STAGE PLANS:
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: 'store channel' (type: string), concat('store', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(22,2)), _col3 (type: decimal(23,2))
+                  expressions: 'store channel' (type: string), concat('store', _col0) (type: string), _col1 (type: decimal(17,2)), _col2 (type: decimal(17,2)), _col3 (type: decimal(18,2))
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4
                   Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
@@ -918,7 +918,7 @@ STAGE PLANS:
                       Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
                       Statistics: Num rows: 2435062716 Data size: 264270971781 Basic stats: COMPLETE Column stats: NONE
                       TopN Hash Memory Usage: 0.1
-                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(32,2)), _col5 (type: decimal(33,2))
+                      value expressions: _col3 (type: decimal(27,2)), _col4 (type: decimal(27,2)), _col5 (type: decimal(28,2))
         Reducer 6 
             Execution mode: vectorized
             Reduce Operator Tree:
@@ -930,7 +930,7 @@ STAGE PLANS:
                 Statistics: Num rows: 1217531358 Data size: 132135485890 Basic stats: COMPLETE Column stats: NONE
                 pruneGroupingSetId: true
                 Select Operator
-                  expressions: _col0 (type: string), _col1 (type: string), _col3 (type: decimal(27,2)), _col4 (type: decimal(32,2)), _col5 (type: decimal(33,2))
+                  expressions: _col0 (type: string), _col1 (type: string), _col3 (type: decimal(27,2)), _col4 (type: decimal(27,2)), _col5 (type: decimal(28,2))
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4
                   Statistics: Num rows: 1217531358 Data size: 132135485890 Basic stats: COMPLETE Column stats: NONE
                   Reduce Output Operator
@@ -938,12 +938,12 @@ STAGE PLANS:
                     sort order: ++
                     Statistics: Num rows: 1217531358 Data size: 132135485890 Basic stats: COMPLETE Column stats: NONE
                     TopN Hash Memory Usage: 0.1
-                    value expressions: _col2 (type: decimal(27,2)), _col3 (type: decimal(32,2)), _col4 (type: decimal(33,2))
+                    value expressions: _col2 (type: decimal(27,2)), _col3 (type: decimal(27,2)), _col4 (type: decimal(28,2))
         Reducer 7 
             Execution mode: vectorized
             Reduce Operator Tree:
               Select Operator
-                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string), VALUE._col0 (type: decimal(27,2)), VALUE._col1 (type: decimal(32,2)), VALUE._col2 (type: decimal(33,2))
+                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string), VALUE._col0 (type: decimal(27,2)), VALUE._col1 (type: decimal(27,2)), VALUE._col2 (type: decimal(28,2))
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4
                 Statistics: Num rows: 1217531358 Data size: 132135485890 Basic stats: COMPLETE Column stats: NONE
                 Limit
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
index f867f46..26a98ff 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
@@ -131,7 +131,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC])
       HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
         HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
           HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
-            HiveProject($f0=[$3], $f1=[CASE($4, $1, null:NULL)], $f2=[CASE($5, $1, null:NULL)], $f3=[CASE($6, $1, null:NULL)], $f4=[CASE($7, $1, null:NULL)], $f5=[CASE($8, $1, null:NULL)], $f6=[CASE($9, $1, null:NULL)], $f7=[CASE($10, $1, null:NULL)])
+            HiveProject($f0=[$3], $f1=[CASE($4, $1, null:DECIMAL(7, 2))], $f2=[CASE($5, $1, null:DECIMAL(7, 2))], $f3=[CASE($6, $1, null:DECIMAL(7, 2))], $f4=[CASE($7, $1, null:DECIMAL(7, 2))], $f5=[CASE($8, $1, null:DECIMAL(7, 2))], $f6=[CASE($9, $1, null:DECIMAL(7, 2))], $f7=[CASE($10, $1, null:DECIMAL(7, 2))])
               HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                 HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
                   HiveUnion(all=[true])
@@ -151,7 +151,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC])
         HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
-              HiveProject($f0=[$3], $f1=[CASE($4, $1, null:NULL)], $f2=[CASE($5, $1, null:NULL)], $f3=[CASE($6, $1, null:NULL)], $f4=[CASE($7, $1, null:NULL)], $f5=[CASE($8, $1, null:NULL)], $f6=[CASE($9, $1, null:NULL)], $f7=[CASE($10, $1, null:NULL)])
+              HiveProject($f0=[$3], $f1=[CASE($4, $1, null:DECIMAL(7, 2))], $f2=[CASE($5, $1, null:DECIMAL(7, 2))], $f3=[CASE($6, $1, null:DECIMAL(7, 2))], $f4=[CASE($7, $1, null:DECIMAL(7, 2))], $f5=[CASE($8, $1, null:DECIMAL(7, 2))], $f6=[CASE($9, $1, null:DECIMAL(7, 2))], $f7=[CASE($10, $1, null:DECIMAL(7, 2))])
                 HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
                     HiveUnion(all=[true])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
index 2ffb2a6..4f566d0 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
@@ -65,7 +65,7 @@ HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[
   HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$6], sort5=[$7], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC])
     HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[$2], cov=[$3], w_warehouse_sk0=[$4], i_item_sk0=[$5], mean0=[$6], cov0=[$7])
       HiveJoin(condition=[AND(=($1, $5), =($0, $4))], joinType=[inner], algorithm=[none], cost=[not available])
-        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null:NULL, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)))])
+        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null:DOUBLE, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)))])
           HiveFilter(condition=[CASE(=(/(CAST($6):DOUBLE, $5), 0), false, >(/(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)), 1))])
             HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
               HiveProject($f0=[$7], $f1=[$6], $f2=[$0], $f4=[$4], $f40=[CAST($4):DOUBLE], $f6=[*(CAST($4):DOUBLE, CAST($4):DOUBLE)])
@@ -84,7 +84,7 @@ HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[
                   HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
                     HiveFilter(condition=[IS NOT NULL($0)])
                       HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
-        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null:NULL, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)))])
+        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null:DOUBLE, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)))])
           HiveFilter(condition=[CASE(=(/(CAST($6):DOUBLE, $5), 0), false, >(/(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null:BIGINT, -($5, 1))), 0.5:DECIMAL(2, 1)), /(CAST($6):DOUBLE, $5)), 1))])
             HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
               HiveProject($f0=[$7], $f1=[$6], $f2=[$0], $f4=[$4], $f40=[CAST($4):DOUBLE], $f6=[*(CAST($4):DOUBLE, CAST($4):DOUBLE)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
index adb6e9c..09939b5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
@@ -68,7 +68,7 @@ CBO PLAN:
 HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
   HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
     HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
-      HiveProject($f0=[$1], $f1=[$14], $f2=[CASE($11, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)], $f3=[CASE($12, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)])
+      HiveProject($f0=[$1], $f1=[$14], $f2=[CASE($11, -($6, CASE(IS NOT NULL($9), $9, 0:DECIMAL(12, 2))), 0:DECIMAL(13, 2))], $f3=[CASE($12, -($6, CASE(IS NOT NULL($9), $9, 0:DECIMAL(12, 2))), 0:DECIMAL(13, 2))])
         HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject(w_warehouse_sk=[$0], w_state=[$10])
             HiveFilter(condition=[IS NOT NULL($0)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
index 6d6d30a..d017e2c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
@@ -46,7 +46,7 @@ CBO PLAN:
 HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], fetch=[100])
   HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
     HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
-      HiveProject($f0=[$13], $f1=[$12], $f2=[CASE($4, $2, null:NULL)], $f3=[CASE($5, $2, null:NULL)], $f4=[CASE($6, $2, null:NULL)], $f5=[CASE($7, $2, null:NULL)], $f6=[CASE($8, $2, null:NULL)], $f7=[CASE($9, $2, null:NULL)], $f8=[CASE($10, $2, null:NULL)])
+      HiveProject($f0=[$13], $f1=[$12], $f2=[CASE($4, $2, null:DECIMAL(7, 2))], $f3=[CASE($5, $2, null:DECIMAL(7, 2))], $f4=[CASE($6, $2, null:DECIMAL(7, 2))], $f5=[CASE($7, $2, null:DECIMAL(7, 2))], $f6=[CASE($8, $2, null:DECIMAL(7, 2))], $f7=[CASE($9, $2, null:DECIMAL(7, 2))], $f8=[CASE($10, $2, null:DECIMAL(7, 2))])
         HiveJoin(condition=[=($11, $1)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
index 2d058c3..1e28ff9 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
@@ -282,11 +282,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
                         HiveProject(ws_item_sk=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                           HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
                             HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                              HiveProject(wr_item_sk=[$2], wr_order_number=[$13], CASE=[CASE(IS NOT NULL($14), $14, 0)], CASE3=[CASE(IS NOT NULL($15), $15, 0)])
+                              HiveProject(wr_item_sk=[$2], wr_order_number=[$13], CASE=[CASE(IS NOT NULL($14), $14, 0)], CASE3=[CASE(IS NOT NULL($15), $15, 0:DECIMAL(12, 2))])
                                 HiveFilter(condition=[AND(>($15, 10000:DECIMAL(5, 0)), IS NOT NULL($13), IS NOT NULL($2))])
                                   HiveTableScan(table=[[default, web_returns]], table:alias=[wr])
                               HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0)])
+                                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0:DECIMAL(12, 2))])
                                   HiveFilter(condition=[AND(>($33, 1:DECIMAL(1, 0)), >($29, 0:DECIMAL(1, 0)), >($18, 0), IS NOT NULL($17), IS NOT NULL($3), IS NOT NULL($0))])
                                     HiveTableScan(table=[[default, web_sales]], table:alias=[ws])
                                 HiveProject(d_date_sk=[$0])
@@ -298,11 +298,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
                         HiveProject(cs_item_sk=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                           HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
                             HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                              HiveProject(cr_item_sk=[$2], cr_order_number=[$16], CASE=[CASE(IS NOT NULL($17), $17, 0)], CASE3=[CASE(IS NOT NULL($18), $18, 0)])
+                              HiveProject(cr_item_sk=[$2], cr_order_number=[$16], CASE=[CASE(IS NOT NULL($17), $17, 0)], CASE3=[CASE(IS NOT NULL($18), $18, 0:DECIMAL(12, 2))])
                                 HiveFilter(condition=[AND(>($18, 10000:DECIMAL(5, 0)), IS NOT NULL($16), IS NOT NULL($2))])
                                   HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr])
                               HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                                HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0)])
+                                HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], CASE=[CASE(IS NOT NULL($18), $18, 0)], CASE4=[CASE(IS NOT NULL($29), $29, 0:DECIMAL(12, 2))])
                                   HiveFilter(condition=[AND(>($33, 1:DECIMAL(1, 0)), >($29, 0:DECIMAL(1, 0)), >($18, 0), IS NOT NULL($17), IS NOT NULL($15), IS NOT NULL($0))])
                                     HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs])
                                 HiveProject(d_date_sk=[$0])
@@ -314,11 +314,11 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
                 HiveProject(ss_item_sk=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                   HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($7)], agg#2=[sum($3)], agg#3=[sum($8)])
                     HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                      HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE3=[CASE(IS NOT NULL($11), $11, 0)])
+                      HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE3=[CASE(IS NOT NULL($11), $11, 0:DECIMAL(12, 2))])
                         HiveFilter(condition=[AND(>($11, 10000:DECIMAL(5, 0)), IS NOT NULL($9), IS NOT NULL($2))])
                           HiveTableScan(table=[[default, store_returns]], table:alias=[sr])
                       HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE4=[CASE(IS NOT NULL($20), $20, 0)])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], CASE=[CASE(IS NOT NULL($10), $10, 0)], CASE4=[CASE(IS NOT NULL($20), $20, 0:DECIMAL(12, 2))])
                           HiveFilter(condition=[AND(>($22, 1:DECIMAL(1, 0)), >($20, 0:DECIMAL(1, 0)), >($10, 0), IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($0))])
                             HiveTableScan(table=[[default, store_sales]], table:alias=[sts])
                         HiveProject(d_date_sk=[$0])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
index bcf9e3d..abc5d99 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
@@ -103,7 +103,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
         HiveJoin(condition=[=($9, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
             HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
-              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:NULL)], $f3=[CASE($6, $2, null:NULL)], $f4=[CASE($7, $2, null:NULL)], $f5=[CASE($8, $2, null:NULL)], $f6=[CASE($9, $2, null:NULL)], $f7=[CASE($10, $2, null:NULL)], $f8=[CASE($11, $2, null:NULL)])
+              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:DECIMAL(7, 2))], $f3=[CASE($6, $2, null:DECIMAL(7, 2))], $f4=[CASE($7, $2, null:DECIMAL(7, 2))], $f5=[CASE($8, $2, null:DECIMAL(7, 2))], $f6=[CASE($9, $2, null:DECIMAL(7, 2))], $f7=[CASE($10, $2, null:DECIMAL(7, 2))], $f8=[CASE($11, $2, null:DECIMAL(7, 2))])
                 HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
                     HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
@@ -122,7 +122,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
           HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
               HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($5)], agg#3=[sum($6)], agg#4=[sum($7)], agg#5=[sum($8)])
-                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:NULL)], $f3=[CASE($6, $2, null:NULL)], $f4=[CASE($7, $2, null:NULL)], $f5=[CASE($8, $2, null:NULL)], $f6=[CASE($9, $2, null:NULL)], $f7=[CASE($10, $2, null:NULL)], $f8=[CASE($11, $2, null:NULL)])
+                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:DECIMAL(7, 2))], $f3=[CASE($6, $2, null:DECIMAL(7, 2))], $f4=[CASE($7, $2, null:DECIMAL(7, 2))], $f5=[CASE($8, $2, null:DECIMAL(7, 2))], $f6=[CASE($9, $2, null:DECIMAL(7, 2))], $f7=[CASE($10, $2, null:DECIMAL(7, 2))], $f8=[CASE($11, $2, null:DECIMAL(7, 2))])
                   HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
                       HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
index db1ce36..b5b85e5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
@@ -463,7 +463,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
           HiveUnion(all=[true])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
               HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
-                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE($15, $11, 0)], $f8=[CASE($16, $11, 0)], $f9=[CASE($17, $11, 0)], $f10=[CASE($18, $11, 0)], $f11=[CASE($19, $11, 0)], $f12=[CASE($20, $11, 0)], $f13=[CASE($21, $11, 0)], $f14=[CASE($22, $11, 0)], $f15=[CASE($23, $11, 0)], $f16=[CASE($24, $11, 0)], $f17=[CASE($25, $11, 0)], $f18=[CASE($26, $11, 0)], $f19=[CASE($15, $12, 0)], $f20=[CASE($16, $12, 0)], $f21=[CASE($17, $12, 0)], $f22=[CASE($18, $ [...]
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE($15, $11, 0:DECIMAL(18, 2))], $f8=[CASE($16, $11, 0:DECIMAL(18, 2))], $f9=[CASE($17, $11, 0:DECIMAL(18, 2))], $f10=[CASE($18, $11, 0:DECIMAL(18, 2))], $f11=[CASE($19, $11, 0:DECIMAL(18, 2))], $f12=[CASE($20, $11, 0:DECIMAL(18, 2))], $f13=[CASE($21, $11, 0:DECIMAL(18, 2))], $f14=[CASE($22, $11, 0:DECIMAL(18, 2))], $f15=[CASE($23, $11, 0:DECIMAL(18, 2))], $f16=[CASE($24, $11, 0:DECIMAL(18, 2)) [...]
                   HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
                       HiveFilter(condition=[IS NOT NULL($0)])
@@ -485,7 +485,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
                           HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
               HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
-                HiveProject($f0=[$22], $f1=[$23], $f2=[$24], $f3=[$25], $f4=[$26], $f5=[$27], $f7=[CASE($8, $4, 0)], $f8=[CASE($9, $4, 0)], $f9=[CASE($10, $4, 0)], $f10=[CASE($11, $4, 0)], $f11=[CASE($12, $4, 0)], $f12=[CASE($13, $4, 0)], $f13=[CASE($14, $4, 0)], $f14=[CASE($15, $4, 0)], $f15=[CASE($16, $4, 0)], $f16=[CASE($17, $4, 0)], $f17=[CASE($18, $4, 0)], $f18=[CASE($19, $4, 0)], $f19=[CASE($8, $5, 0)], $f20=[CASE($9, $5, 0)], $f21=[CASE($10, $5, 0)], $f22=[CASE($11, $5, 0)], $f23= [...]
+                HiveProject($f0=[$22], $f1=[$23], $f2=[$24], $f3=[$25], $f4=[$26], $f5=[$27], $f7=[CASE($8, $4, 0:DECIMAL(18, 2))], $f8=[CASE($9, $4, 0:DECIMAL(18, 2))], $f9=[CASE($10, $4, 0:DECIMAL(18, 2))], $f10=[CASE($11, $4, 0:DECIMAL(18, 2))], $f11=[CASE($12, $4, 0:DECIMAL(18, 2))], $f12=[CASE($13, $4, 0:DECIMAL(18, 2))], $f13=[CASE($14, $4, 0:DECIMAL(18, 2))], $f14=[CASE($15, $4, 0:DECIMAL(18, 2))], $f15=[CASE($16, $4, 0:DECIMAL(18, 2))], $f16=[CASE($17, $4, 0:DECIMAL(18, 2))], $f1 [...]
                   HiveJoin(condition=[=($3, $21)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveJoin(condition=[=($2, $20)], joinType=[inner], algorithm=[none], cost=[not available])
                       HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
index fb8b35e..29ff348 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
@@ -237,7 +237,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
     HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
       HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
         HiveUnion(all=[true])
-          HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+          HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0:DECIMAL(17, 2))], profit=[-($2, CASE(IS NOT NULL($5), $5, 0:DECIMAL(17, 2)))])
             HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
               HiveProject(s_store_sk=[$0], $f1=[$1], $f2=[$2])
                 HiveAggregate(group=[{5}], agg#0=[sum($2)], agg#1=[sum($3)])
@@ -285,7 +285,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                     HiveProject(d_date_sk=[$0])
                       HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00:TIMESTAMP(9), 1998-09-03 00:00:00:TIMESTAMP(9)), IS NOT NULL($0))])
                         HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
-          HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+          HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0:DECIMAL(17, 2))], profit=[-($2, CASE(IS NOT NULL($5), $5, 0:DECIMAL(17, 2)))])
             HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
               HiveProject(wp_web_page_sk=[$0], $f1=[$1], $f2=[$2])
                 HiveAggregate(group=[{0}], agg#0=[sum($3)], agg#1=[sum($4)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
index 0c314a6..f77eadf 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
@@ -132,7 +132,7 @@ CBO PLAN:
 HiveSortLimit(fetch=[100])
   HiveProject(ss_sold_year=[CAST(2000):INTEGER], ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[$2], store_qty=[$3], store_wholesale_cost=[$4], store_sales_price=[$5], other_chan_qty=[$6], other_chan_wholesale_cost=[$7], other_chan_sales_price=[$8])
     HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$9], sort3=[$10], sort4=[$11], sort5=[$6], sort6=[$7], sort7=[$8], sort8=[$12], dir0=[ASC], dir1=[ASC], dir2=[DESC-nulls-last], dir3=[DESC-nulls-last], dir4=[DESC-nulls-last], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC])
-      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND($12, IS NOT NULL($7)), +($7, $11), 1)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($7), $7, 0), $13)], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($8), $8, 0), $14)], other_chan_sales_price=[+(CASE(IS NOT NULL($9), $9, 0), $15)], ss_qty=[$2], ss_wc=[$3], ss_sp=[$4], (tok_function round (/ (tok_table_or_col ss_qty)  [...]
+      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND($12, IS NOT NULL($7)), +($7, $11), 1:BIGINT)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($7), $7, 0:BIGINT), $13)], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($8), $8, 0:DECIMAL(17, 2)), $14)], other_chan_sales_price=[+(CASE(IS NOT NULL($9), $9, 0:DECIMAL(17, 2)), $15)], ss_qty=[$2], ss_wc=[$3], ss_sp=[$4], (tok_ [...]
         HiveJoin(condition=[=($10, $1)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveJoin(condition=[AND(=($5, $0), =($6, $1))], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
@@ -166,7 +166,7 @@ HiveSortLimit(fetch=[100])
                           HiveProject(wr_item_sk=[$2], wr_order_number=[$13])
                             HiveFilter(condition=[AND(IS NOT NULL($13), IS NOT NULL($2))])
                               HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
-          HiveProject($f2=[$1], $f3=[$2], IS NOT NULL=[IS NOT NULL($2)], CASE=[CASE(IS NOT NULL($2), $2, 0)], CASE7=[CASE(IS NOT NULL($3), $3, 0)], CASE8=[CASE(IS NOT NULL($4), $4, 0)])
+          HiveProject($f2=[$1], $f3=[$2], IS NOT NULL=[IS NOT NULL($2)], CASE=[CASE(IS NOT NULL($2), $2, 0:BIGINT)], CASE7=[CASE(IS NOT NULL($3), $3, 0:DECIMAL(17, 2))], CASE8=[CASE(IS NOT NULL($4), $4, 0:DECIMAL(17, 2))])
             HiveFilter(condition=[>($2, 0)])
               HiveProject(cs_item_sk=[$1], cs_bill_customer_sk=[$0], $f2=[$2], $f3=[$3], $f4=[$4])
                 HiveAggregate(group=[{2, 3}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
index 5387d71..7f479b3 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
@@ -222,7 +222,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
         HiveUnion(all=[true])
           HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2))], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(s_store_sk=[$0], s_store_id=[$1])
                     HiveFilter(condition=[IS NOT NULL($0)])
@@ -248,7 +248,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                         HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
           HiveProject(channel=[_UTF-16LE'catalog channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2))], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
                     HiveFilter(condition=[IS NOT NULL($0)])
@@ -274,7 +274,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                         HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
           HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$15], $f1=[$7], $f2=[CASE(IS NOT NULL($11), $11, 0)], $f3=[-($8, CASE(IS NOT NULL($12), $12, 0))])
+              HiveProject($f0=[$15], $f1=[$7], $f2=[CASE(IS NOT NULL($11), $11, 0:DECIMAL(12, 2))], $f3=[-($8, CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(p_promo_sk=[$0])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
index 30ecde8..4c90da4 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
@@ -131,7 +131,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC])
       HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
         HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
           HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
-            HiveProject($f0=[$3], $f1=[CASE($4, $1, null:NULL)], $f2=[CASE($5, $1, null:NULL)], $f3=[CASE($6, $1, null:NULL)], $f4=[CASE($7, $1, null:NULL)], $f5=[CASE($8, $1, null:NULL)], $f6=[CASE($9, $1, null:NULL)], $f7=[CASE($10, $1, null:NULL)])
+            HiveProject($f0=[$3], $f1=[CASE($4, $1, null:DECIMAL(7, 2))], $f2=[CASE($5, $1, null:DECIMAL(7, 2))], $f3=[CASE($6, $1, null:DECIMAL(7, 2))], $f4=[CASE($7, $1, null:DECIMAL(7, 2))], $f5=[CASE($8, $1, null:DECIMAL(7, 2))], $f6=[CASE($9, $1, null:DECIMAL(7, 2))], $f7=[CASE($10, $1, null:DECIMAL(7, 2))])
               HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                 HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
                   HiveUnion(all=[true])
@@ -151,7 +151,7 @@ HiveSortLimit(sort0=[$0], dir0=[ASC])
         HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
-              HiveProject($f0=[$3], $f1=[CASE($4, $1, null:NULL)], $f2=[CASE($5, $1, null:NULL)], $f3=[CASE($6, $1, null:NULL)], $f4=[CASE($7, $1, null:NULL)], $f5=[CASE($8, $1, null:NULL)], $f6=[CASE($9, $1, null:NULL)], $f7=[CASE($10, $1, null:NULL)])
+              HiveProject($f0=[$3], $f1=[CASE($4, $1, null:DECIMAL(7, 2))], $f2=[CASE($5, $1, null:DECIMAL(7, 2))], $f3=[CASE($6, $1, null:DECIMAL(7, 2))], $f4=[CASE($7, $1, null:DECIMAL(7, 2))], $f5=[CASE($8, $1, null:DECIMAL(7, 2))], $f6=[CASE($9, $1, null:DECIMAL(7, 2))], $f7=[CASE($10, $1, null:DECIMAL(7, 2))])
                 HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
                     HiveUnion(all=[true])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
index ec236ee..fc4e7e3 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
@@ -65,7 +65,7 @@ HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[
   HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$6], sort5=[$7], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC])
     HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[$6], cov=[$7], w_warehouse_sk0=[$0], i_item_sk0=[$1], mean0=[$2], cov0=[$3])
       HiveJoin(condition=[AND(=($5, $1), =($4, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null:NULL, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)))])
+        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null:DOUBLE, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)))])
           HiveFilter(condition=[CASE(=(/(CAST($5):DOUBLE, $4), 0), false, >(/(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)), 1))])
             HiveAggregate(group=[{1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
               HiveProject($f0=[$6], $f1=[$5], $f2=[$3], $f4=[$2], $f40=[CAST($2):DOUBLE], $f6=[*(CAST($2):DOUBLE, CAST($2):DOUBLE)])
@@ -78,7 +78,7 @@ HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[
                         HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
                   HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
                     HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
-        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null:NULL, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)))])
+        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null:DOUBLE, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)))])
           HiveFilter(condition=[CASE(=(/(CAST($5):DOUBLE, $4), 0), false, >(/(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null:BIGINT, -($4, 1))), 0.5:DECIMAL(2, 1)), /(CAST($5):DOUBLE, $4)), 1))])
             HiveAggregate(group=[{1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
               HiveProject($f0=[$6], $f1=[$5], $f2=[$3], $f4=[$2], $f40=[CAST($2):DOUBLE], $f6=[*(CAST($2):DOUBLE, CAST($2):DOUBLE)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
index 1aa3fa8..f71c0b5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
@@ -68,7 +68,7 @@ CBO PLAN:
 HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
   HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
     HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
-      HiveProject($f0=[$1], $f1=[$14], $f2=[CASE($11, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)], $f3=[CASE($12, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)])
+      HiveProject($f0=[$1], $f1=[$14], $f2=[CASE($11, -($6, CASE(IS NOT NULL($9), $9, 0:DECIMAL(12, 2))), 0:DECIMAL(13, 2))], $f3=[CASE($12, -($6, CASE(IS NOT NULL($9), $9, 0:DECIMAL(12, 2))), 0:DECIMAL(13, 2))])
         HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject(w_warehouse_sk=[$0], w_state=[$10])
             HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
index 6058e4c..4eb819b 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
@@ -46,7 +46,7 @@ CBO PLAN:
 HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], fetch=[100])
   HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
     HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
-      HiveProject($f0=[$13], $f1=[$12], $f2=[CASE($4, $2, null:NULL)], $f3=[CASE($5, $2, null:NULL)], $f4=[CASE($6, $2, null:NULL)], $f5=[CASE($7, $2, null:NULL)], $f6=[CASE($8, $2, null:NULL)], $f7=[CASE($9, $2, null:NULL)], $f8=[CASE($10, $2, null:NULL)])
+      HiveProject($f0=[$13], $f1=[$12], $f2=[CASE($4, $2, null:DECIMAL(7, 2))], $f3=[CASE($5, $2, null:DECIMAL(7, 2))], $f4=[CASE($6, $2, null:DECIMAL(7, 2))], $f5=[CASE($7, $2, null:DECIMAL(7, 2))], $f6=[CASE($8, $2, null:DECIMAL(7, 2))], $f7=[CASE($9, $2, null:DECIMAL(7, 2))], $f8=[CASE($10, $2, null:DECIMAL(7, 2))])
         HiveJoin(condition=[=($11, $1)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
index af1b332..b499ae9 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
@@ -281,7 +281,7 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
                       HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
                         HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                           HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
-                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0:DECIMAL(12, 2))], $f4=[CASE(IS NOT NULL($8), $8, 0:DECIMAL(12, 2))])
                               HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
                                 HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
                                   HiveFilter(condition=[>($15, 10000:DECIMAL(5, 0))])
@@ -298,7 +298,7 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
                       HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
                         HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                           HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
-                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0:DECIMAL(12, 2))], $f4=[CASE(IS NOT NULL($8), $8, 0:DECIMAL(12, 2))])
                               HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
                                 HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
                                   HiveFilter(condition=[>($18, 10000:DECIMAL(5, 0))])
@@ -315,7 +315,7 @@ HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[
               HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
                 HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
                   HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
-                    HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                    HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0:DECIMAL(12, 2))], $f4=[CASE(IS NOT NULL($8), $8, 0:DECIMAL(12, 2))])
                       HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
                         HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
                           HiveFilter(condition=[>($11, 10000:DECIMAL(5, 0))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
index 68081a5..8d17cc7 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
@@ -102,7 +102,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
         HiveJoin(condition=[=($9, $0)], joinType=[inner], algorithm=[none], cost=[not available])
           HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
             HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
-              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:NULL)], $f3=[CASE($6, $2, null:NULL)], $f4=[CASE($7, $2, null:NULL)], $f5=[CASE($8, $2, null:NULL)], $f6=[CASE($9, $2, null:NULL)], $f7=[CASE($10, $2, null:NULL)], $f8=[CASE($11, $2, null:NULL)])
+              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:DECIMAL(7, 2))], $f3=[CASE($6, $2, null:DECIMAL(7, 2))], $f4=[CASE($7, $2, null:DECIMAL(7, 2))], $f5=[CASE($8, $2, null:DECIMAL(7, 2))], $f6=[CASE($9, $2, null:DECIMAL(7, 2))], $f7=[CASE($10, $2, null:DECIMAL(7, 2))], $f8=[CASE($11, $2, null:DECIMAL(7, 2))])
                 HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
                     HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
@@ -120,7 +120,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[
           HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
               HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($5)], agg#3=[sum($6)], agg#4=[sum($7)], agg#5=[sum($8)])
-                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:NULL)], $f3=[CASE($6, $2, null:NULL)], $f4=[CASE($7, $2, null:NULL)], $f5=[CASE($8, $2, null:NULL)], $f6=[CASE($9, $2, null:NULL)], $f7=[CASE($10, $2, null:NULL)], $f8=[CASE($11, $2, null:NULL)])
+                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null:DECIMAL(7, 2))], $f3=[CASE($6, $2, null:DECIMAL(7, 2))], $f4=[CASE($7, $2, null:DECIMAL(7, 2))], $f5=[CASE($8, $2, null:DECIMAL(7, 2))], $f6=[CASE($9, $2, null:DECIMAL(7, 2))], $f7=[CASE($10, $2, null:DECIMAL(7, 2))], $f8=[CASE($11, $2, null:DECIMAL(7, 2))])
                   HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
                       HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
index b3de4c1..34cddac 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
@@ -463,7 +463,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
           HiveUnion(all=[true])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
               HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
-                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE($15, $11, 0)], $f8=[CASE($16, $11, 0)], $f9=[CASE($17, $11, 0)], $f10=[CASE($18, $11, 0)], $f11=[CASE($19, $11, 0)], $f12=[CASE($20, $11, 0)], $f13=[CASE($21, $11, 0)], $f14=[CASE($22, $11, 0)], $f15=[CASE($23, $11, 0)], $f16=[CASE($24, $11, 0)], $f17=[CASE($25, $11, 0)], $f18=[CASE($26, $11, 0)], $f19=[CASE($15, $12, 0)], $f20=[CASE($16, $12, 0)], $f21=[CASE($17, $12, 0)], $f22=[CASE($18, $ [...]
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE($15, $11, 0:DECIMAL(18, 2))], $f8=[CASE($16, $11, 0:DECIMAL(18, 2))], $f9=[CASE($17, $11, 0:DECIMAL(18, 2))], $f10=[CASE($18, $11, 0:DECIMAL(18, 2))], $f11=[CASE($19, $11, 0:DECIMAL(18, 2))], $f12=[CASE($20, $11, 0:DECIMAL(18, 2))], $f13=[CASE($21, $11, 0:DECIMAL(18, 2))], $f14=[CASE($22, $11, 0:DECIMAL(18, 2))], $f15=[CASE($23, $11, 0:DECIMAL(18, 2))], $f16=[CASE($24, $11, 0:DECIMAL(18, 2)) [...]
                   HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
                       HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
@@ -484,7 +484,7 @@ HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county
                           HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
             HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
               HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
-                HiveProject($f0=[$22], $f1=[$23], $f2=[$24], $f3=[$25], $f4=[$26], $f5=[$27], $f7=[CASE($8, $4, 0)], $f8=[CASE($9, $4, 0)], $f9=[CASE($10, $4, 0)], $f10=[CASE($11, $4, 0)], $f11=[CASE($12, $4, 0)], $f12=[CASE($13, $4, 0)], $f13=[CASE($14, $4, 0)], $f14=[CASE($15, $4, 0)], $f15=[CASE($16, $4, 0)], $f16=[CASE($17, $4, 0)], $f17=[CASE($18, $4, 0)], $f18=[CASE($19, $4, 0)], $f19=[CASE($8, $5, 0)], $f20=[CASE($9, $5, 0)], $f21=[CASE($10, $5, 0)], $f22=[CASE($11, $5, 0)], $f23= [...]
+                HiveProject($f0=[$22], $f1=[$23], $f2=[$24], $f3=[$25], $f4=[$26], $f5=[$27], $f7=[CASE($8, $4, 0:DECIMAL(18, 2))], $f8=[CASE($9, $4, 0:DECIMAL(18, 2))], $f9=[CASE($10, $4, 0:DECIMAL(18, 2))], $f10=[CASE($11, $4, 0:DECIMAL(18, 2))], $f11=[CASE($12, $4, 0:DECIMAL(18, 2))], $f12=[CASE($13, $4, 0:DECIMAL(18, 2))], $f13=[CASE($14, $4, 0:DECIMAL(18, 2))], $f14=[CASE($15, $4, 0:DECIMAL(18, 2))], $f15=[CASE($16, $4, 0:DECIMAL(18, 2))], $f16=[CASE($17, $4, 0:DECIMAL(18, 2))], $f1 [...]
                   HiveJoin(condition=[=($3, $21)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveJoin(condition=[=($2, $20)], joinType=[inner], algorithm=[none], cost=[not available])
                       HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
index e06aef4..7aebc6f 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
@@ -237,7 +237,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
     HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
       HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
         HiveUnion(all=[true])
-          HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+          HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0:DECIMAL(17, 2))], profit=[-($2, CASE(IS NOT NULL($5), $5, 0:DECIMAL(17, 2)))])
             HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
               HiveProject(ss_store_sk=[$0], $f1=[$1], $f2=[$2])
                 HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
@@ -279,7 +279,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                     HiveProject(d_date_sk=[$0])
                       HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00:TIMESTAMP(9), 1998-09-03 00:00:00:TIMESTAMP(9))])
                         HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
-          HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+          HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0:DECIMAL(17, 2))], profit=[-($2, CASE(IS NOT NULL($5), $5, 0:DECIMAL(17, 2)))])
             HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
               HiveProject(ws_web_page_sk=[$0], $f1=[$1], $f2=[$2])
                 HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
index 9893ebc..d55c397 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
@@ -132,7 +132,7 @@ CBO PLAN:
 HiveSortLimit(fetch=[100])
   HiveProject(ss_sold_year=[CAST(2000):INTEGER], ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[$2], store_qty=[$3], store_wholesale_cost=[$4], store_sales_price=[$5], other_chan_qty=[$6], other_chan_wholesale_cost=[$7], other_chan_sales_price=[$8])
     HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$9], sort3=[$10], sort4=[$11], sort5=[$6], sort6=[$7], sort7=[$8], sort8=[$12], dir0=[ASC], dir1=[ASC], dir2=[DESC-nulls-last], dir3=[DESC-nulls-last], dir4=[DESC-nulls-last], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC])
-      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($11), IS NOT NULL($6)), +($11, $6), 1)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($11), $11, 0), CASE(IS NOT NULL($6), $6, 0))], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($12), $12, 0), CASE(IS NOT NULL($7), $7, 0))], other_chan_sales_price=[+(CASE(IS NOT NULL($13), $13, 0), CASE(IS NOT NULL($8), $8 [...]
+      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($11), IS NOT NULL($6)), +($11, $6), 1:BIGINT)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($11), $11, 0:BIGINT), CASE(IS NOT NULL($6), $6, 0:BIGINT))], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($12), $12, 0:DECIMAL(17, 2)), CASE(IS NOT NULL($7), $7, 0:DECIMAL(17, 2)))], other_chan_sales_price=[+(CASE( [...]
         HiveJoin(condition=[AND(=($9, $0), =($10, $1))], joinType=[inner], algorithm=[none], cost=[not available])
           HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
             HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
index 5187d2a..685a200 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
@@ -222,7 +222,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
         HiveUnion(all=[true])
           HiveProject(channel=[_UTF-16LE'store channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2))], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(s_store_sk=[$0], s_store_id=[$1])
                     HiveTableScan(table=[[default, store]], table:alias=[store])
@@ -246,7 +246,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                         HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
           HiveProject(channel=[_UTF-16LE'catalog channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2))], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
                     HiveTableScan(table=[[default, catalog_page]], table:alias=[catalog_page])
@@ -270,7 +270,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
                         HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
           HiveProject(channel=[_UTF-16LE'web channel':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$2], profit=[$3])
             HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
-              HiveProject($f0=[$15], $f1=[$7], $f2=[CASE(IS NOT NULL($11), $11, 0)], $f3=[-($8, CASE(IS NOT NULL($12), $12, 0))])
+              HiveProject($f0=[$15], $f1=[$7], $f2=[CASE(IS NOT NULL($11), $11, 0:DECIMAL(12, 2))], $f3=[-($8, CASE(IS NOT NULL($12), $12, 0:DECIMAL(12, 2)))])
                 HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
                   HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
                     HiveProject(p_promo_sk=[$0])
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query67.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query67.q.out
index cf7b13b..f70f1bd 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query67.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/mv_query67.q.out
@@ -477,7 +477,7 @@ HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=
             HiveJoin(condition=[=($1, $10)], joinType=[inner], algorithm=[none], cost=[not available])
               HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
                 HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
-                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], CASE=[CASE(AND(IS NOT NULL($13), IS NOT NULL(CAST($10):DECIMAL(10, 0))), *($13, CAST($10):DECIMAL(10, 0)), 0)])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], CASE=[CASE(AND(IS NOT NULL($13), IS NOT NULL(CAST($10):DECIMAL(10, 0))), *($13, CAST($10):DECIMAL(10, 0)), 0:DECIMAL(18, 2))])
                     HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
                       HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
                   HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8], d_qoy=[$10])
diff --git a/ql/src/test/results/clientpositive/semijoin5.q.out b/ql/src/test/results/clientpositive/semijoin5.q.out
index a193428..3d41ca6 100644
--- a/ql/src/test/results/clientpositive/semijoin5.q.out
+++ b/ql/src/test/results/clientpositive/semijoin5.q.out
@@ -182,7 +182,7 @@ STAGE PLANS:
                         window frame: ROWS PRECEDING(MAX)~FOLLOWING(48)
             Statistics: Num rows: 1 Data size: 212 Basic stats: COMPLETE Column stats: NONE
             Select Operator
-              expressions: 498 (type: int), (_col7 + UDFToInteger(_col5)) (type: int), floor(_col3) (type: bigint), CASE WHEN (sum_window_0 is not null) THEN (sum_window_0) ELSE (704) END (type: bigint)
+              expressions: 498 (type: int), (_col7 + UDFToInteger(_col5)) (type: int), floor(_col3) (type: bigint), CASE WHEN (sum_window_0 is not null) THEN (sum_window_0) ELSE (704L) END (type: bigint)
               outputColumnNames: _col0, _col1, _col2, _col3
               Statistics: Num rows: 1 Data size: 212 Basic stats: COMPLETE Column stats: NONE
               File Output Operator
diff --git a/ql/src/test/results/clientpositive/spark/subquery_select.q.out b/ql/src/test/results/clientpositive/spark/subquery_select.q.out
index 1b1528b..b201eb3 100644
--- a/ql/src/test/results/clientpositive/spark/subquery_select.q.out
+++ b/ql/src/test/results/clientpositive/spark/subquery_select.q.out
@@ -3928,10 +3928,14 @@ STAGE PLANS:
                 mode: mergepartial
                 outputColumnNames: _col0
                 Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
+                Select Operator
+                  expressions: UDFToDouble(_col0) (type: double)
+                  outputColumnNames: _col0
                   Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: int)
+                  Reduce Output Operator
+                    sort order: 
+                    Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+                    value expressions: _col0 (type: double)
         Reducer 2 
             Reduce Operator Tree:
               Join Operator
diff --git a/ql/src/test/results/clientpositive/union_offcbo.q.out b/ql/src/test/results/clientpositive/union_offcbo.q.out
index 76d99da..53aa264 100644
--- a/ql/src/test/results/clientpositive/union_offcbo.q.out
+++ b/ql/src/test/results/clientpositive/union_offcbo.q.out
@@ -644,7 +644,7 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
           Statistics: Num rows: 1 Data size: 220 Basic stats: COMPLETE Column stats: NONE
           Filter Operator
-            predicate: (((COALESCE(_col0,-1) <> COALESCE(_col7,-1)) or (COALESCE(_col1,-1) <> COALESCE(_col8,-1))) and (CASE WHEN ((_col0 is null and (_col3 >= '2016-02-05') and _col7 is not null)) THEN ('DEL') WHEN ((_col0 is null and (_col3 <= '2016-02-05') and _col7 is not null)) THEN ('RET') WHEN (((_col7 = _col0) and (_col8 <> _col1))) THEN ('A_INS') ELSE ('NA') END <> 'RET')) (type: boolean)
+            predicate: (((COALESCE(_col0,-1) <> COALESCE(_col7,-1)) or (COALESCE(_col1,-1) <> COALESCE(_col8,-1))) and ((_col0 is null and (_col3 >= '2016-02-05')) or (_col0 is null and (_col3 <= '2016-02-05')) is not true)) (type: boolean)
             Statistics: Num rows: 1 Data size: 220 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: _col2 (type: bigint), _col5 (type: string), _col6 (type: bigint), _col4 (type: string), _col7 (type: string), _col8 (type: string), CASE WHEN ((_col0 is null and (_col3 >= '2016-02-05') and _col7 is not null)) THEN ('DEL') WHEN ((_col0 is null and (_col3 <= '2016-02-05') and _col7 is not null)) THEN ('RET') WHEN (((_col7 = _col0) and (_col8 <> _col1))) THEN ('A_INS') ELSE ('NA') END (type: string)
@@ -739,7 +739,7 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
           Statistics: Num rows: 1 Data size: 422 Basic stats: COMPLETE Column stats: NONE
           Filter Operator
-            predicate: (((COALESCE(_col3,-1) <> COALESCE(_col6,-1)) or (COALESCE(_col4,-1) <> COALESCE(_col7,-1))) and (CASE WHEN ((_col3 is null and (_col5 <= '2015-11-20') and _col6 is not null)) THEN ('DEL') WHEN (((_col6 is null and _col3 is not null) or ((_col6 = _col3) and (_col7 <> _col4)))) THEN ('INS') ELSE ('NA') END <> 'RET')) (type: boolean)
+            predicate: ((COALESCE(_col3,-1) <> COALESCE(_col6,-1)) or (COALESCE(_col4,-1) <> COALESCE(_col7,-1))) (type: boolean)
             Statistics: Num rows: 1 Data size: 422 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: _col0 (type: bigint), _col1 (type: string), _col2 (type: bigint), '2099-12-31' (type: string), _col3 (type: string), _col4 (type: string), CASE WHEN ((_col3 is null and (_col5 <= '2015-11-20') and _col6 is not null)) THEN ('DEL') WHEN (((_col6 is null and _col3 is not null) or ((_col6 = _col3) and (_col7 <> _col4)))) THEN ('INS') ELSE ('NA') END (type: string)
@@ -1713,7 +1713,7 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
           Statistics: Num rows: 1 Data size: 220 Basic stats: COMPLETE Column stats: NONE
           Filter Operator
-            predicate: (((COALESCE(_col0,-1) <> COALESCE(_col7,-1)) or (COALESCE(_col1,-1) <> COALESCE(_col8,-1))) and (CASE WHEN ((_col0 is null and (_col3 >= '2016-02-05') and _col7 is not null)) THEN ('DEL') WHEN ((_col0 is null and (_col3 <= '2016-02-05') and _col7 is not null)) THEN ('RET') WHEN (((_col7 = _col0) and (_col8 <> _col1))) THEN ('A_INS') ELSE ('NA') END <> 'RET')) (type: boolean)
+            predicate: (((COALESCE(_col0,-1) <> COALESCE(_col7,-1)) or (COALESCE(_col1,-1) <> COALESCE(_col8,-1))) and ((_col0 is null and (_col3 >= '2016-02-05')) or (_col0 is null and (_col3 <= '2016-02-05')) is not true)) (type: boolean)
             Statistics: Num rows: 1 Data size: 220 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: _col2 (type: bigint), _col5 (type: string), _col6 (type: bigint), _col4 (type: string), _col7 (type: string), _col8 (type: string), CASE WHEN ((_col0 is null and (_col3 >= '2016-02-05') and _col7 is not null)) THEN ('DEL') WHEN ((_col0 is null and (_col3 <= '2016-02-05') and _col7 is not null)) THEN ('RET') WHEN (((_col7 = _col0) and (_col8 <> _col1))) THEN ('A_INS') ELSE ('NA') END (type: string)
@@ -1806,7 +1806,7 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
           Statistics: Num rows: 1 Data size: 422 Basic stats: COMPLETE Column stats: NONE
           Filter Operator
-            predicate: (((COALESCE(_col3,-1) <> COALESCE(_col6,-1)) or (COALESCE(_col4,-1) <> COALESCE(_col7,-1))) and (CASE WHEN ((_col3 is null and (_col5 <= '2015-11-20') and _col6 is not null)) THEN ('DEL') WHEN (((_col6 is null and _col3 is not null) or ((_col6 = _col3) and (_col7 <> _col4)))) THEN ('INS') ELSE ('NA') END <> 'RET')) (type: boolean)
+            predicate: ((COALESCE(_col3,-1) <> COALESCE(_col6,-1)) or (COALESCE(_col4,-1) <> COALESCE(_col7,-1))) (type: boolean)
             Statistics: Num rows: 1 Data size: 422 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: _col0 (type: bigint), _col1 (type: string), _col2 (type: bigint), '2099-12-31' (type: string), _col3 (type: string), _col4 (type: string), CASE WHEN ((_col3 is null and (_col5 <= '2015-11-20') and _col6 is not null)) THEN ('DEL') WHEN (((_col6 is null and _col3 is not null) or ((_col6 = _col3) and (_col7 <> _col4)))) THEN ('INS') ELSE ('NA') END (type: string)
diff --git a/ql/src/test/results/clientpositive/vector_case_when_1.q.out b/ql/src/test/results/clientpositive/vector_case_when_1.q.out
index bedfd54..d6c8a3d 100644
--- a/ql/src/test/results/clientpositive/vector_case_when_1.q.out
+++ b/ql/src/test/results/clientpositive/vector_case_when_1.q.out
@@ -206,13 +206,13 @@ STAGE PLANS:
                 native: true
                 vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
             Select Operator
-              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
+              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
                   projectedOutputColumnNums: [4, 21, 26, 30, 34, 38, 42, 44, 46, 48, 50, 52, 54, 58, 61, 64, 67]
-                  selectExpressions: VectorUDFAdaptor(CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, LongColLessLongScalar(col 4:int, val 100) -> 20:boolean) -> 21:string, Ve [...]
+                  selectExpressions: VectorUDFAdaptor(CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, LongColLessLongScalar(col 4:int, val 100) -> 20:boolean) -> 21:string, Ve [...]
               Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
               File Output Operator
                 compressed: false
@@ -539,13 +539,13 @@ STAGE PLANS:
                 native: true
                 vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
             Select Operator
-              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
+              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
-                  projectedOutputColumnNums: [4, 24, 33, 40, 44, 49, 53, 55, 57, 59, 61, 63, 65, 69, 72, 75, 78]
-                  selectExpressions: IfExprStringScalarStringGroupColumn(col 17:boolean, val Singlecol 23:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, IfExprStringScalarStringGroupColumn(col 18:boolean, val Twocol 22:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, IfExprStringScalarStringGroupColumn(col 19:boolean, val Somecol 21:string)(children: LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, IfExprStringScalarStringScalar( [...]
+                  projectedOutputColumnNums: [4, 24, 33, 40, 44, 48, 52, 54, 56, 58, 60, 62, 64, 68, 71, 74, 77]
+                  selectExpressions: IfExprStringScalarStringGroupColumn(col 17:boolean, val Singlecol 23:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, IfExprStringScalarStringGroupColumn(col 18:boolean, val Twocol 22:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 18:boolean, IfExprStringScalarStringGroupColumn(col 19:boolean, val Somecol 21:string)(children: LongColLessLongScalar(col 4:int, val 10) -> 19:boolean, IfExprStringScalarStringScalar( [...]
               Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
               File Output Operator
                 compressed: false
@@ -572,7 +572,7 @@ STAGE PLANS:
               includeColumns: [1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14]
               dataColumns: l_orderkey:int, l_partkey:int, l_suppkey:int, l_linenumber:int, l_quantity:int, l_extendedprice:double, l_discount:double, l_tax:decimal(10,2)/DECIMAL_64, l_returnflag:char(1), l_linestatus:char(1), l_shipdate:date, l_commitdate:date, l_receiptdate:date, l_shipinstruct:varchar(20), l_shipmode:char(10), l_comment:string
               partitionColumnCount: 0
-              scratchColumnTypeNames: [bigint, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, string, string, string, string, string, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, bigint, double, double, double, double, bigint, double, double, double, bigint, decimal(10,2), bigint, decimal(10,2), bigint, decimal(12,2), bigint, decimal(12,2), bigint, decimal(10,2)/DECIMAL_64, bigint, decimal(10,2)/DECIMAL_6 [...]
+              scratchColumnTypeNames: [bigint, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, string, string, string, string, string, bigint, bigint, bigint, string, string, string, string, bigint, bigint, bigint, bigint, bigint, double, double, double, bigint, double, double, double, bigint, decimal(10,2), bigint, decimal(10,2), bigint, decimal(12,2), bigint, decimal(12,2), bigint, decimal(10,2)/DECIMAL_64, bigint, decimal(10,2)/DECIMAL_64, bigin [...]
 
   Stage: Stage-0
     Fetch Operator
@@ -872,13 +872,13 @@ STAGE PLANS:
                 native: true
                 vectorizationSchemaColumns: [0:l_orderkey:int, 1:l_partkey:int, 2:l_suppkey:int, 3:l_linenumber:int, 4:l_quantity:int, 5:l_extendedprice:double, 6:l_discount:double, 7:l_tax:decimal(10,2)/DECIMAL_64, 8:l_returnflag:char(1), 9:l_linestatus:char(1), 10:l_shipdate:date, 11:l_commitdate:date, 12:l_receiptdate:date, 13:l_shipinstruct:varchar(20), 14:l_shipmode:char(10), 15:l_comment:string, 16:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
             Select Operator
-              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
+              expressions: l_quantity (type: int), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE ('Huge number') END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') WHEN ((l_quantity = 2)) THEN ('Two') WHEN ((l_quantity < 10)) THEN ('Some') WHEN ((l_quantity < 100)) THEN ('Many') ELSE (null) END (type: string), CASE WHEN ((l_quantity = 1)) THEN ('Single') W [...]
               outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13, _col14, _col15, _col16
               Select Vectorization:
                   className: VectorSelectOperator
                   native: true
                   projectedOutputColumnNums: [4, 27, 39, 48, 52, 57, 62, 64, 66, 71, 76, 78, 80, 84, 87, 90, 93]
-                  selectExpressions: IfExprColumnCondExpr(col 17:boolean, col 18:stringcol 26:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, ConstantVectorExpression(val Single) -> 18:string, IfExprColumnCondExpr(col 19:boolean, col 20:stringcol 25:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 19:boolean, ConstantVectorExpression(val Two) -> 20:string, IfExprColumnCondExpr(col 21:boolean, col 22:stringcol 24:string)(children: LongColLessLongScal [...]
+                  selectExpressions: IfExprColumnCondExpr(col 17:boolean, col 18:stringcol 26:string)(children: LongColEqualLongScalar(col 4:int, val 1) -> 17:boolean, ConstantVectorExpression(val Single) -> 18:string, IfExprColumnCondExpr(col 19:boolean, col 20:stringcol 25:string)(children: LongColEqualLongScalar(col 4:int, val 2) -> 19:boolean, ConstantVectorExpression(val Two) -> 20:string, IfExprColumnCondExpr(col 21:boolean, col 22:stringcol 24:string)(children: LongColLessLongScal [...]
               Statistics: Num rows: 101 Data size: 141804 Basic stats: COMPLETE Column stats: COMPLETE
               File Output Operator
                 compressed: false
diff --git a/ql/src/test/results/clientpositive/vector_case_when_2.q.out b/ql/src/test/results/clientpositive/vector_case_when_2.q.out
index aba9ff2..2d4dc5b 100644
--- a/ql/src/test/results/clientpositive/vector_case_when_2.q.out
+++ b/ql/src/test/results/clientpositive/vector_case_when_2.q.out
@@ -839,3 +839,231 @@ ctimestamp1	ctimestamp2	ctimestamp2_description	ctimestamp2_description_2	ctimes
 9209-11-11 04:08:58.223768453	9209-11-10 02:05:54.223768453	Unknown	NULL	NULL	9209	2018-03-08 23:04:59	8	NULL	9209-11-12
 9403-01-09 18:12:33.547	9403-01-08 16:09:29.547	Unknown	NULL	NULL	9403	2018-03-08 23:04:59	12	NULL	9404-01-09
 NULL	NULL	Unknown	NULL	NULL	NULL	2018-03-08 23:04:59	NULL	NULL	NULL
+PREHOOK: query: create temporary table foo(q548284 int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@foo
+POSTHOOK: query: create temporary table foo(q548284 int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@foo
+PREHOOK: query: insert into foo values(1),(2),(3),(4),(5),(6)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@foo
+POSTHOOK: query: insert into foo values(1),(2),(3),(4),(5),(6)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@foo
+POSTHOOK: Lineage: foo.q548284 SCRIPT []
+col1
+PREHOOK: query: explain vectorization detail select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: explain vectorization detail select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+Explain
+PLAN VECTORIZATION:
+  enabled: true
+  enabledConditionsMet: [hive.vectorized.execution.enabled IS true]
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: foo
+            Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+            TableScan Vectorization:
+                native: true
+                vectorizationSchemaColumns: [0:q548284:int, 1:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
+            Select Operator
+              expressions: q548284 (type: int), CASE WHEN ((q548284 = 1)) THEN (0.2) WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END (type: decimal(11,1))
+              outputColumnNames: _col0, _col1
+              Select Vectorization:
+                  className: VectorSelectOperator
+                  native: true
+                  projectedOutputColumnNums: [0, 16]
+                  selectExpressions: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(11,1)col 15:decimal(11,1))(children: LongColEqualLongScalar(col 0:int, val 1) -> 2:boolean, ConstantVectorExpression(val 0.2) -> 3:decimal(11,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(11,1)col 14:decimal(11,1))(children: LongColEqualLongScalar(col 0:int, val 2) -> 4:boolean, ConstantVectorExpression(val 0.4) -> 5:decimal(11,1), IfExprCondExprCondExpr(col 6:boolean, col 7:decimal(11,1)co [...]
+              Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+              Reduce Output Operator
+                key expressions: _col0 (type: int)
+                sort order: +
+                Reduce Sink Vectorization:
+                    className: VectorReduceSinkOperator
+                    native: false
+                    nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                    nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+                Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                TopN Hash Memory Usage: 0.1
+                value expressions: _col1 (type: decimal(11,1))
+      Execution mode: vectorized
+      Map Vectorization:
+          enabled: true
+          enabledConditionsMet: hive.vectorized.use.vector.serde.deserialize IS true
+          inputFormatFeatureSupport: [DECIMAL_64]
+          featureSupportInUse: [DECIMAL_64]
+          inputFileFormats: org.apache.hadoop.mapred.TextInputFormat
+          allNative: false
+          usesVectorUDFAdaptor: false
+          vectorized: true
+          rowBatchContext:
+              dataColumnCount: 1
+              includeColumns: [0]
+              dataColumns: q548284:int
+              partitionColumnCount: 0
+              scratchColumnTypeNames: [bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), bigint, decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1), decimal(11,1)]
+      Reduce Vectorization:
+          enabled: false
+          enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true
+          enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+      Reduce Operator Tree:
+        Select Operator
+          expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(11,1))
+          outputColumnNames: _col0, _col1
+          Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+          Limit
+            Number of rows: 1
+            Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: select q548284, CASE WHEN ((q548284 = 1)) THEN (0.2)
+    WHEN ((q548284 = 2)) THEN (0.4) WHEN ((q548284 = 3)) THEN (0.6) WHEN ((q548284 = 4))
+    THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (null) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+q548284	_c1
+1	0.2
+PREHOOK: query: explain vectorization detail select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8)
+    WHEN ((q548284 = 5)) THEN (1) ELSE (8) END from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: explain vectorization detail select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8)
+    WHEN ((q548284 = 5)) THEN (1) ELSE (8) END from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+Explain
+PLAN VECTORIZATION:
+  enabled: true
+  enabledConditionsMet: [hive.vectorized.execution.enabled IS true]
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: foo
+            Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+            TableScan Vectorization:
+                native: true
+                vectorizationSchemaColumns: [0:q548284:int, 1:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
+            Select Operator
+              expressions: q548284 (type: int), CASE WHEN ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END (type: decimal(2,1))
+              outputColumnNames: _col0, _col1
+              Select Vectorization:
+                  className: VectorSelectOperator
+                  native: true
+                  projectedOutputColumnNums: [0, 8]
+                  selectExpressions: IfExprCondExprCondExpr(col 2:boolean, col 3:decimal(2,1)col 7:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 4) -> 2:boolean, ConstantVectorExpression(val 0.8) -> 3:decimal(2,1), IfExprCondExprCondExpr(col 4:boolean, col 5:decimal(2,1)col 6:decimal(2,1))(children: LongColEqualLongScalar(col 0:int, val 5) -> 4:boolean, ConstantVectorExpression(val 1) -> 5:decimal(2,1), ConstantVectorExpression(val 8) -> 6:decimal(2,1)) -> 7:decimal(2,1)) [...]
+              Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+              Reduce Output Operator
+                key expressions: _col0 (type: int)
+                sort order: +
+                Reduce Sink Vectorization:
+                    className: VectorReduceSinkOperator
+                    native: false
+                    nativeConditionsMet: hive.vectorized.execution.reducesink.new.enabled IS true, No PTF TopN IS true, No DISTINCT columns IS true, BinarySortableSerDe for keys IS true, LazyBinarySerDe for values IS true
+                    nativeConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+                Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+                TopN Hash Memory Usage: 0.1
+                value expressions: _col1 (type: decimal(2,1))
+      Execution mode: vectorized
+      Map Vectorization:
+          enabled: true
+          enabledConditionsMet: hive.vectorized.use.vector.serde.deserialize IS true
+          inputFormatFeatureSupport: [DECIMAL_64]
+          featureSupportInUse: [DECIMAL_64]
+          inputFileFormats: org.apache.hadoop.mapred.TextInputFormat
+          allNative: false
+          usesVectorUDFAdaptor: false
+          vectorized: true
+          rowBatchContext:
+              dataColumnCount: 1
+              includeColumns: [0]
+              dataColumns: q548284:int
+              partitionColumnCount: 0
+              scratchColumnTypeNames: [bigint, decimal(2,1), bigint, decimal(2,1), decimal(2,1), decimal(2,1), decimal(2,1)]
+      Reduce Vectorization:
+          enabled: false
+          enableConditionsMet: hive.vectorized.execution.reduce.enabled IS true
+          enableConditionsNotMet: hive.execution.engine mr IN [tez, spark] IS false
+      Reduce Operator Tree:
+        Select Operator
+          expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: decimal(2,1))
+          outputColumnNames: _col0, _col1
+          Statistics: Num rows: 6 Data size: 24 Basic stats: COMPLETE Column stats: NONE
+          Limit
+            Number of rows: 1
+            Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+            File Output Operator
+              compressed: false
+              Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: NONE
+              table:
+                  input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                  serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END
+    from foo order by q548284 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@foo
+#### A masked pattern was here ####
+POSTHOOK: query: select q548284, CASE WHEN  ((q548284 = 4)) THEN (0.8) WHEN ((q548284 = 5)) THEN (1) ELSE (8) END
+    from foo order by q548284 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@foo
+#### A masked pattern was here ####
+q548284	_c1
+1	8.0
diff --git a/ql/src/test/results/clientpositive/vector_coalesce.q.out b/ql/src/test/results/clientpositive/vector_coalesce.q.out
index eac2d43..1ab2d6e 100644
--- a/ql/src/test/results/clientpositive/vector_coalesce.q.out
+++ b/ql/src/test/results/clientpositive/vector_coalesce.q.out
@@ -125,7 +125,7 @@ STAGE PLANS:
                     className: VectorSelectOperator
                     native: true
                     projectedOutputColumnNums: [5, 2, 20]
-                    selectExpressions: IfExprCondExprCondExpr(col 16:boolean, col 18:doublecol 19:double)(children: ColAndCol(col 13:boolean, col 15:boolean)(children: IsNotNull(col 5:double) -> 13:boolean, IsNotNull(col 14:double)(children: FuncLog2LongToDouble(col 2:int) -> 14:double) -> 15:boolean) -> 16:boolean, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: FuncLog2LongToDouble(col 2:int) -> 17:double) -> 18:double, ConstantVectorExpression(val 0.0) -> 19:double) -> [...]
+                    selectExpressions: IfExprCondExprColumn(col 16:boolean, col 18:double, col 19:double)(children: ColAndCol(col 13:boolean, col 15:boolean)(children: IsNotNull(col 5:double) -> 13:boolean, IsNotNull(col 14:double)(children: FuncLog2LongToDouble(col 2:int) -> 14:double) -> 15:boolean) -> 16:boolean, DoubleColAddDoubleColumn(col 5:double, col 17:double)(children: FuncLog2LongToDouble(col 2:int) -> 17:double) -> 18:double, ConstantVectorExpression(val 0.0) -> 19:double) -> [...]
                   Reduce Sink Vectorization:
                       className: VectorReduceSinkOperator
                       native: false