You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2020/01/18 15:42:31 UTC

[hive] 02/02: HIVE-22735: TopNKey operator deduplication (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)

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

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

commit f0f46b794c30067fc19049f76a0b02f19cb37e04
Author: Krisztian Kasa <kk...@cloudera.com>
AuthorDate: Sat Jan 18 07:19:39 2020 -0800

    HIVE-22735: TopNKey operator deduplication (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)
---
 .../apache/hadoop/hive/ql/plan/TopNKeyDesc.java    |  20 +-
 .../llap/topnkey_grouping_sets.q.out               | 304 +++++++++------------
 .../llap/topnkey_grouping_sets_order.q.out         |  80 +++---
 .../llap/vector_groupby_grouping_sets_limit.q.out  | 264 ++++++++----------
 .../perf/tez/constraints/query14.q.out             |   6 +-
 .../perf/tez/constraints/query27.q.out             | 152 +++++------
 .../perf/tez/constraints/query5.q.out              |   6 +-
 .../perf/tez/constraints/query77.q.out             |   6 +-
 .../perf/tez/constraints/query80.q.out             |   6 +-
 .../results/clientpositive/perf/tez/query14.q.out  |   6 +-
 .../results/clientpositive/perf/tez/query27.q.out  | 156 ++++++-----
 .../results/clientpositive/perf/tez/query5.q.out   |   6 +-
 .../results/clientpositive/perf/tez/query77.q.out  |   6 +-
 .../results/clientpositive/perf/tez/query80.q.out  |   6 +-
 14 files changed, 470 insertions(+), 554 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/TopNKeyDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/TopNKeyDesc.java
index a9e2a52..f752967 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/TopNKeyDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/TopNKeyDesc.java
@@ -46,9 +46,23 @@ public class TopNKeyDesc extends AbstractOperatorDesc {
       final List<ExprNodeDesc> keyColumns) {
 
     this.topN = topN;
-    this.columnSortOrder = columnSortOrder;
-    this.nullOrder = nullOrder;
-    this.keyColumns = keyColumns;
+
+    this.keyColumns = new ArrayList<>(keyColumns.size());
+    StringBuilder sortOrder = new StringBuilder(columnSortOrder.length());
+    StringBuilder nullSortOrder = new StringBuilder(nullOrder.length());
+
+    for (int i = 0; i < keyColumns.size(); ++i) {
+      ExprNodeDesc keyExpression = keyColumns.get(i);
+      if (keyExpression instanceof ExprNodeConstantDesc) {
+        continue;
+      }
+      this.keyColumns.add(keyExpression);
+      sortOrder.append(columnSortOrder.charAt(i));
+      nullSortOrder.append(nullOrder.charAt(i));
+    }
+
+    this.columnSortOrder = sortOrder.toString();
+    this.nullOrder = nullSortOrder.toString();
   }
 
   @Explain(displayName = "top n", explainLevels = { Level.DEFAULT, Level.EXTENDED, Level.USER })
diff --git a/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets.q.out b/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets.q.out
index 542aedd..41a8c3a 100644
--- a/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets.q.out
+++ b/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets.q.out
@@ -72,34 +72,28 @@ STAGE PLANS:
                   alias: t_test_grouping_sets
                   Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
                   Top N Key Operator
-                    sort order: +
-                    keys: a (type: int)
-                    null sort order: z
+                    sort order: ++
+                    keys: a (type: int), b (type: int)
+                    null sort order: zz
                     Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
                     top n: 3
                     Select Operator
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: _col0, _col1
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: +++
+                      Group By Operator
                         keys: _col0 (type: int), _col1 (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 3
-                        Group By Operator
-                          keys: _col0 (type: int), _col1 (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: +++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: +++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -109,16 +103,16 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2
-                Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                 Select Operator
                   expressions: _col0 (type: int), _col1 (type: int), grouping(_col2, 1L) (type: bigint), grouping(_col2, 0L) (type: bigint), grouping(_col2, 1L, 0L) (type: bigint)
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4
-                  Statistics: Num rows: 26 Data size: 632 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 712 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: int)
                     null sort order: z
                     sort order: +
-                    Statistics: Num rows: 26 Data size: 632 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 26 Data size: 712 Basic stats: COMPLETE Column stats: COMPLETE
                     TopN Hash Memory Usage: 0.1
                     value expressions: _col1 (type: int), _col2 (type: bigint), _col3 (type: bigint), _col4 (type: bigint)
         Reducer 3 
@@ -127,13 +121,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: int), VALUE._col1 (type: bigint), VALUE._col2 (type: bigint), VALUE._col3 (type: bigint)
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4
-                Statistics: Num rows: 26 Data size: 632 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 712 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 3
-                  Statistics: Num rows: 3 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 3 Data size: 88 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 3 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 3 Data size: 88 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -196,34 +190,28 @@ STAGE PLANS:
                   alias: t_test_grouping_sets
                   Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
                   Top N Key Operator
-                    sort order: +
-                    keys: a (type: int)
-                    null sort order: z
+                    sort order: ++
+                    keys: a (type: int), b (type: int)
+                    null sort order: zz
                     Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
                     top n: 10
                     Select Operator
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: +++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 10
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: +++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: +++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -233,13 +221,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int)
                   null sort order: z
                   sort order: +
-                  Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
                   value expressions: _col1 (type: int)
         Reducer 3 
@@ -248,13 +236,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), VALUE._col0 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 88 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 10
-                  Statistics: Num rows: 10 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 10 Data size: 40 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 10 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 10 Data size: 40 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -279,11 +267,11 @@ POSTHOOK: Input: default@t_test_grouping_sets
 5	NULL
 6	NULL
 6	2
-7	NULL
 7	8
+7	NULL
 10	11
 10	NULL
-NULL	1
+NULL	2
 PREHOOK: query: SELECT a, b FROM t_test_grouping_sets GROUP BY a,b GROUPING SETS ((a,b), (a), (b), ()) ORDER BY a LIMIT 10
 PREHOOK: type: QUERY
 PREHOOK: Input: default@t_test_grouping_sets
@@ -686,25 +674,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -714,13 +696,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: zz
                   sort order: -+
-                  Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -728,13 +710,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -814,25 +796,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -842,13 +818,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: zz
                   sort order: -+
-                  Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -856,13 +832,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -942,25 +918,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -970,13 +940,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: zz
                   sort order: -+
-                  Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -984,13 +954,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -1070,25 +1040,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -1098,13 +1062,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: zz
                   sort order: -+
-                  Statistics: Num rows: 13 Data size: 112 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 13 Data size: 152 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -1112,13 +1076,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 13 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 13 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -1225,27 +1189,21 @@ STAGE PLANS:
                   mode: mergepartial
                   outputColumnNames: _col0, _col1, _col2
                   Statistics: Num rows: 6 Data size: 36 Basic stats: COMPLETE Column stats: COMPLETE
-                  Top N Key Operator
-                    sort order: -++
+                  Group By Operator
+                    aggregations: max(_col2)
                     keys: _col0 (type: int), _col1 (type: int), 0L (type: bigint)
-                    null sort order: zzz
-                    Statistics: Num rows: 6 Data size: 36 Basic stats: COMPLETE Column stats: COMPLETE
-                    top n: 7
-                    Group By Operator
-                      aggregations: max(_col2)
-                      keys: _col0 (type: int), _col1 (type: int), 0L (type: bigint)
-                      minReductionHashAggr: 0.0
-                      mode: hash
-                      outputColumnNames: _col0, _col1, _col2, _col3
-                      Statistics: Num rows: 6 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Reduce Output Operator
-                        key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                        null sort order: zzz
-                        sort order: -++
-                        Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                        Statistics: Num rows: 6 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        TopN Hash Memory Usage: 0.1
-                        value expressions: _col3 (type: int)
+                    minReductionHashAggr: 0.0
+                    mode: hash
+                    outputColumnNames: _col0, _col1, _col2, _col3
+                    Statistics: Num rows: 6 Data size: 96 Basic stats: COMPLETE Column stats: COMPLETE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                      null sort order: zzz
+                      sort order: -++
+                      Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                      Statistics: Num rows: 6 Data size: 96 Basic stats: COMPLETE Column stats: COMPLETE
+                      TopN Hash Memory Usage: 0.1
+                      value expressions: _col3 (type: int)
         Reducer 3 
             Execution mode: llap
             Reduce Operator Tree:
@@ -1254,17 +1212,17 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col3
-                Statistics: Num rows: 6 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 6 Data size: 96 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Select Operator
                   expressions: _col0 (type: int), _col1 (type: int), _col3 (type: int)
                   outputColumnNames: _col0, _col1, _col2
-                  Statistics: Num rows: 6 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                   Reduce Output Operator
                     key expressions: _col0 (type: int), _col1 (type: int)
                     null sort order: zz
                     sort order: -+
-                    Statistics: Num rows: 6 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                     TopN Hash Memory Usage: 0.1
                     value expressions: _col2 (type: int)
         Reducer 4 
@@ -1273,13 +1231,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int), VALUE._col0 (type: int)
                 outputColumnNames: _col0, _col1, _col2
-                Statistics: Num rows: 6 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 6 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 6 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 6 Data size: 48 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets_order.q.out b/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets_order.q.out
index d8afde1..d6d76fb 100644
--- a/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets_order.q.out
+++ b/ql/src/test/results/clientpositive/llap/topnkey_grouping_sets_order.q.out
@@ -325,25 +325,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -353,13 +347,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: zz
                   sort order: -+
-                  Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -367,13 +361,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 88 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -453,25 +447,19 @@ STAGE PLANS:
                       expressions: a (type: int), b (type: int)
                       outputColumnNames: a, b
                       Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: -++
+                      Group By Operator
                         keys: a (type: int), b (type: int), 0L (type: bigint)
-                        null sort order: aaz
-                        Statistics: Num rows: 13 Data size: 80 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 7
-                        Group By Operator
-                          keys: a (type: int), b (type: int), 0L (type: bigint)
-                          minReductionHashAggr: 0.15384614
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2
-                          Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            null sort order: aaz
-                            sort order: -++
-                            Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
-                            Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                        minReductionHashAggr: 0.15384614
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          null sort order: aaz
+                          sort order: -++
+                          Map-reduce partition columns: _col0 (type: int), _col1 (type: int), _col2 (type: bigint)
+                          Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
+                          TopN Hash Memory Usage: 0.1
             Execution mode: llap
             LLAP IO: no inputs
         Reducer 2 
@@ -481,13 +469,13 @@ STAGE PLANS:
                 keys: KEY._col0 (type: int), KEY._col1 (type: int), KEY._col2 (type: bigint)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                 pruneGroupingSetId: true
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col1 (type: int)
                   null sort order: aa
                   sort order: -+
-                  Statistics: Num rows: 26 Data size: 216 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 26 Data size: 296 Basic stats: COMPLETE Column stats: COMPLETE
                   TopN Hash Memory Usage: 0.1
         Reducer 3 
             Execution mode: llap
@@ -495,13 +483,13 @@ STAGE PLANS:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: int), KEY.reducesinkkey1 (type: int)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 26 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Statistics: Num rows: 26 Data size: 88 Basic stats: COMPLETE Column stats: COMPLETE
                 Limit
                   Number of rows: 7
-                  Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                   File Output Operator
                     compressed: false
-                    Statistics: Num rows: 7 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    Statistics: Num rows: 7 Data size: 32 Basic stats: COMPLETE Column stats: COMPLETE
                     table:
                         input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                         output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
diff --git a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
index ea7f073..b7ea749 100644
--- a/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
+++ b/ql/src/test/results/clientpositive/llap/vector_groupby_grouping_sets_limit.q.out
@@ -82,45 +82,35 @@ STAGE PLANS:
                           native: true
                           projectedOutputColumnNums: [0, 1]
                       Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: +++
-                        keys: a (type: string), b (type: string), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 10
-                        Top N Key Vectorization:
-                            className: VectorTopNKeyOperator
+                      Group By Operator
+                        aggregations: count()
+                        Group By Vectorization:
+                            aggregators: VectorUDAFCountStar(*) -> bigint
+                            className: VectorGroupByOperator
+                            groupByMode: HASH
                             keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 4:bigint
-                            native: true
-                        Group By Operator
-                          aggregations: count()
-                          Group By Vectorization:
-                              aggregators: VectorUDAFCountStar(*) -> bigint
-                              className: VectorGroupByOperator
-                              groupByMode: HASH
-                              keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 5:bigint
-                              native: false
-                              vectorProcessingMode: HASH
-                              projectedOutputColumnNums: [0]
-                          keys: a (type: string), b (type: string), 0L (type: bigint)
-                          minReductionHashAggr: 0.0
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2, _col3
+                            native: false
+                            vectorProcessingMode: HASH
+                            projectedOutputColumnNums: [0]
+                        keys: a (type: string), b (type: string), 0L (type: bigint)
+                        minReductionHashAggr: 0.0
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2, _col3
+                        Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: +++
+                          Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          Reduce Sink Vectorization:
+                              className: VectorReduceSinkMultiKeyOperator
+                              keyColumns: 0:string, 1:string, 2:bigint
+                              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: 3:bigint
                           Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: +++
-                            Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            Reduce Sink Vectorization:
-                                className: VectorReduceSinkMultiKeyOperator
-                                keyColumns: 0:string, 1:string, 2:bigint
-                                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: 3:bigint
-                            Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
-                            value expressions: _col3 (type: bigint)
+                          TopN Hash Memory Usage: 0.1
+                          value expressions: _col3 (type: bigint)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -137,7 +127,7 @@ STAGE PLANS:
                     includeColumns: [0, 1]
                     dataColumns: a:string, b:string, c:string
                     partitionColumnCount: 0
-                    scratchColumnTypeNames: [bigint, bigint]
+                    scratchColumnTypeNames: [bigint]
         Reducer 2 
             Execution mode: vectorized, llap
             Reduce Vectorization:
@@ -310,45 +300,35 @@ STAGE PLANS:
                           native: true
                           projectedOutputColumnNums: [0, 1]
                       Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: +++
-                        keys: a (type: string), b (type: string), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 10
-                        Top N Key Vectorization:
-                            className: VectorTopNKeyOperator
+                      Group By Operator
+                        aggregations: count()
+                        Group By Vectorization:
+                            aggregators: VectorUDAFCountStar(*) -> bigint
+                            className: VectorGroupByOperator
+                            groupByMode: HASH
                             keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 4:bigint
-                            native: true
-                        Group By Operator
-                          aggregations: count()
-                          Group By Vectorization:
-                              aggregators: VectorUDAFCountStar(*) -> bigint
-                              className: VectorGroupByOperator
-                              groupByMode: HASH
-                              keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 5:bigint
-                              native: false
-                              vectorProcessingMode: HASH
-                              projectedOutputColumnNums: [0]
-                          keys: a (type: string), b (type: string), 0L (type: bigint)
-                          minReductionHashAggr: 0.0
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2, _col3
+                            native: false
+                            vectorProcessingMode: HASH
+                            projectedOutputColumnNums: [0]
+                        keys: a (type: string), b (type: string), 0L (type: bigint)
+                        minReductionHashAggr: 0.0
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2, _col3
+                        Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: +++
+                          Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          Reduce Sink Vectorization:
+                              className: VectorReduceSinkMultiKeyOperator
+                              keyColumns: 0:string, 1:string, 2:bigint
+                              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: 3:bigint
                           Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: +++
-                            Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            Reduce Sink Vectorization:
-                                className: VectorReduceSinkMultiKeyOperator
-                                keyColumns: 0:string, 1:string, 2:bigint
-                                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: 3:bigint
-                            Statistics: Num rows: 12 Data size: 2232 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
-                            value expressions: _col3 (type: bigint)
+                          TopN Hash Memory Usage: 0.1
+                          value expressions: _col3 (type: bigint)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -365,7 +345,7 @@ STAGE PLANS:
                     includeColumns: [0, 1]
                     dataColumns: a:string, b:string, c:string
                     partitionColumnCount: 0
-                    scratchColumnTypeNames: [bigint, bigint]
+                    scratchColumnTypeNames: [bigint]
         Reducer 2 
             Execution mode: vectorized, llap
             Reduce Vectorization:
@@ -538,45 +518,35 @@ STAGE PLANS:
                           native: true
                           projectedOutputColumnNums: [0, 1]
                       Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: +++
-                        keys: a (type: string), b (type: string), 0L (type: bigint)
-                        null sort order: zzz
-                        Statistics: Num rows: 6 Data size: 1020 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 10
-                        Top N Key Vectorization:
-                            className: VectorTopNKeyOperator
+                      Group By Operator
+                        aggregations: count()
+                        Group By Vectorization:
+                            aggregators: VectorUDAFCountStar(*) -> bigint
+                            className: VectorGroupByOperator
+                            groupByMode: HASH
                             keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 4:bigint
-                            native: true
-                        Group By Operator
-                          aggregations: count()
-                          Group By Vectorization:
-                              aggregators: VectorUDAFCountStar(*) -> bigint
-                              className: VectorGroupByOperator
-                              groupByMode: HASH
-                              keyExpressions: col 0:string, col 1:string, ConstantVectorExpression(val 0) -> 5:bigint
-                              native: false
-                              vectorProcessingMode: HASH
-                              projectedOutputColumnNums: [0]
-                          keys: a (type: string), b (type: string), 0L (type: bigint)
-                          minReductionHashAggr: 0.0
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2, _col3
+                            native: false
+                            vectorProcessingMode: HASH
+                            projectedOutputColumnNums: [0]
+                        keys: a (type: string), b (type: string), 0L (type: bigint)
+                        minReductionHashAggr: 0.0
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2, _col3
+                        Statistics: Num rows: 6 Data size: 1116 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          null sort order: zzz
+                          sort order: +++
+                          Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
+                          Reduce Sink Vectorization:
+                              className: VectorReduceSinkMultiKeyOperator
+                              keyColumns: 0:string, 1:string, 2:bigint
+                              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: 3:bigint
                           Statistics: Num rows: 6 Data size: 1116 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            null sort order: zzz
-                            sort order: +++
-                            Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: bigint)
-                            Reduce Sink Vectorization:
-                                className: VectorReduceSinkMultiKeyOperator
-                                keyColumns: 0:string, 1:string, 2:bigint
-                                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: 3:bigint
-                            Statistics: Num rows: 6 Data size: 1116 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
-                            value expressions: _col3 (type: bigint)
+                          TopN Hash Memory Usage: 0.1
+                          value expressions: _col3 (type: bigint)
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -593,7 +563,7 @@ STAGE PLANS:
                     includeColumns: [0, 1]
                     dataColumns: a:string, b:string, c:string
                     partitionColumnCount: 0
-                    scratchColumnTypeNames: [bigint, bigint]
+                    scratchColumnTypeNames: [bigint]
         Reducer 2 
             Execution mode: vectorized, llap
             Reduce Vectorization:
@@ -749,14 +719,14 @@ STAGE PLANS:
                       native: true
                       vectorizationSchemaColumns: [0:a:string, 1:b:string, 2:c:string, 3:ROW__ID:struct<writeid:bigint,bucketid:int,rowid:bigint>]
                   Top N Key Operator
-                    sort order: +
-                    keys: a (type: string)
-                    null sort order: z
+                    sort order: +++
+                    keys: a (type: string), b (type: string), c (type: string)
+                    null sort order: zzz
                     Statistics: Num rows: 6 Data size: 1530 Basic stats: COMPLETE Column stats: COMPLETE
                     top n: 10
                     Top N Key Vectorization:
                         className: VectorTopNKeyOperator
-                        keyExpressions: col 0:string
+                        keyExpressions: col 0:string, col 1:string, col 2:string
                         native: true
                     Select Operator
                       expressions: a (type: string), b (type: string), c (type: string)
@@ -766,41 +736,31 @@ STAGE PLANS:
                           native: true
                           projectedOutputColumnNums: [0, 1, 2]
                       Statistics: Num rows: 6 Data size: 1530 Basic stats: COMPLETE Column stats: COMPLETE
-                      Top N Key Operator
-                        sort order: ++++
-                        keys: a (type: string), b (type: string), c (type: string), 0L (type: bigint)
-                        null sort order: zzzz
-                        Statistics: Num rows: 6 Data size: 1530 Basic stats: COMPLETE Column stats: COMPLETE
-                        top n: 10
-                        Top N Key Vectorization:
-                            className: VectorTopNKeyOperator
+                      Group By Operator
+                        Group By Vectorization:
+                            className: VectorGroupByOperator
+                            groupByMode: HASH
                             keyExpressions: col 0:string, col 1:string, col 2:string, ConstantVectorExpression(val 0) -> 4:bigint
-                            native: true
-                        Group By Operator
-                          Group By Vectorization:
-                              className: VectorGroupByOperator
-                              groupByMode: HASH
-                              keyExpressions: col 0:string, col 1:string, col 2:string, ConstantVectorExpression(val 0) -> 5:bigint
-                              native: false
-                              vectorProcessingMode: HASH
-                              projectedOutputColumnNums: []
-                          keys: a (type: string), b (type: string), c (type: string), 0L (type: bigint)
-                          minReductionHashAggr: 0.0
-                          mode: hash
-                          outputColumnNames: _col0, _col1, _col2, _col3
+                            native: false
+                            vectorProcessingMode: HASH
+                            projectedOutputColumnNums: []
+                        keys: a (type: string), b (type: string), c (type: string), 0L (type: bigint)
+                        minReductionHashAggr: 0.0
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2, _col3
+                        Statistics: Num rows: 9 Data size: 2367 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: bigint)
+                          null sort order: zzzz
+                          sort order: ++++
+                          Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: bigint)
+                          Reduce Sink Vectorization:
+                              className: VectorReduceSinkMultiKeyOperator
+                              keyColumns: 0:string, 1:string, 2:string, 3:bigint
+                              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
                           Statistics: Num rows: 9 Data size: 2367 Basic stats: COMPLETE Column stats: COMPLETE
-                          Reduce Output Operator
-                            key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: bigint)
-                            null sort order: zzzz
-                            sort order: ++++
-                            Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: bigint)
-                            Reduce Sink Vectorization:
-                                className: VectorReduceSinkMultiKeyOperator
-                                keyColumns: 0:string, 1:string, 2:string, 3:bigint
-                                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
-                            Statistics: Num rows: 9 Data size: 2367 Basic stats: COMPLETE Column stats: COMPLETE
-                            TopN Hash Memory Usage: 0.1
+                          TopN Hash Memory Usage: 0.1
             Execution mode: vectorized, llap
             LLAP IO: all inputs
             Map Vectorization:
@@ -817,7 +777,7 @@ STAGE PLANS:
                     includeColumns: [0, 1, 2]
                     dataColumns: a:string, b:string, c:string
                     partitionColumnCount: 0
-                    scratchColumnTypeNames: [bigint, bigint]
+                    scratchColumnTypeNames: [bigint]
         Reducer 2 
             Execution mode: vectorized, llap
             Reduce Vectorization:
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
index 44da18a..4f811c0 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
@@ -314,7 +314,7 @@ Stage-0
                       Group By Operator [GBY_1208] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1207] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1205] (rows=40576 width=223)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1204] (rows=40576 width=244)
@@ -690,7 +690,7 @@ Stage-0
                       Group By Operator [GBY_1215] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1214] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1212] (rows=40576 width=219)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1211] (rows=40576 width=244)
@@ -877,7 +877,7 @@ Stage-0
                       Group By Operator [GBY_1201] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1200] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1198] (rows=40576 width=221)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1197] (rows=40576 width=244)
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
index 4eb4116..957f883 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
@@ -87,81 +87,79 @@ Stage-0
                     PartitionCols:_col0, _col1, _col2
                     Group By Operator [GBY_28] (rows=13907934 width=570)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col2)","count(_col2)","sum(_col3)","count(_col3)","sum(_col4)","count(_col4)","sum(_col5)","count(_col5)"],keys:_col0, _col1, 0L
-                      Top N Key Operator [TNK_60] (rows=4635978 width=186)
-                        keys:_col0, _col1, 0L,top n:100
-                        Select Operator [SEL_26] (rows=4635978 width=186)
-                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                          Top N Key Operator [TNK_58] (rows=4635978 width=186)
-                            keys:_col13, _col11,top n:100
-                            Merge Join Operator [MERGEJOIN_104] (rows=4635978 width=186)
-                              Conds:RS_23._col1=RS_123._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col11","_col13"]
-                            <-Map 12 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_123]
-                                PartitionCols:_col0
-                                Select Operator [SEL_122] (rows=462000 width=104)
-                                  Output:["_col0","_col1"]
-                                  TableScan [TS_12] (rows=462000 width=104)
-                                    default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
-                            <-Reducer 4 [SIMPLE_EDGE]
-                              SHUFFLE [RS_23]
-                                PartitionCols:_col1
-                                Merge Join Operator [MERGEJOIN_103] (rows=4635978 width=90)
-                                  Conds:RS_20._col3=RS_121._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col11"]
-                                <-Map 11 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_121]
-                                    PartitionCols:_col0
-                                    Select Operator [SEL_120] (rows=209 width=90)
-                                      Output:["_col0","_col1"]
-                                      Filter Operator [FIL_119] (rows=209 width=90)
-                                        predicate:(s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC')
-                                        TableScan [TS_9] (rows=1704 width=90)
-                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
-                                <-Reducer 3 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_20]
-                                    PartitionCols:_col3
-                                    Merge Join Operator [MERGEJOIN_102] (rows=4635978 width=4)
-                                      Conds:RS_17._col0=RS_118._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
-                                    <-Map 10 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_118]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_117] (rows=652 width=4)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_116] (rows=652 width=8)
-                                            predicate:(d_year = 2001)
-                                            TableScan [TS_6] (rows=73049 width=8)
-                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
-                                    <-Reducer 2 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_17]
-                                        PartitionCols:_col0
-                                        Merge Join Operator [MERGEJOIN_101] (rows=4635978 width=4)
-                                          Conds:RS_115._col2=RS_107._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
-                                        <-Map 8 [SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_107]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_106] (rows=14776 width=4)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_105] (rows=14776 width=268)
-                                                predicate:((cd_marital_status = 'U') and (cd_education_status = '2 yr Degree') and (cd_gender = 'M'))
-                                                TableScan [TS_3] (rows=1861800 width=268)
-                                                  default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
-                                        <-Map 1 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_115]
-                                            PartitionCols:_col2
-                                            Select Operator [SEL_114] (rows=501690006 width=340)
-                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                              Filter Operator [FIL_113] (rows=501690006 width=340)
-                                                predicate:(ss_cdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_cdemo_sk BETWEEN DynamicValue(RS_15_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_15_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_15_customer_demographics_cd_demo_sk_bloom_filter)))
-                                                TableScan [TS_0] (rows=575995635 width=340)
-                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
-                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_112]
-                                                    Group By Operator [GBY_111] (rows=1 width=12)
-                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_110]
-                                                        Group By Operator [GBY_109] (rows=1 width=12)
-                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_108] (rows=14776 width=4)
-                                                            Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_106]
+                      Select Operator [SEL_26] (rows=4635978 width=186)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                        Top N Key Operator [TNK_58] (rows=4635978 width=186)
+                          keys:_col13, _col11,top n:100
+                          Merge Join Operator [MERGEJOIN_104] (rows=4635978 width=186)
+                            Conds:RS_23._col1=RS_123._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col11","_col13"]
+                          <-Map 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_123]
+                              PartitionCols:_col0
+                              Select Operator [SEL_122] (rows=462000 width=104)
+                                Output:["_col0","_col1"]
+                                TableScan [TS_12] (rows=462000 width=104)
+                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_23]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_103] (rows=4635978 width=90)
+                                Conds:RS_20._col3=RS_121._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col11"]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_121]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_120] (rows=209 width=90)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_119] (rows=209 width=90)
+                                      predicate:(s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC')
+                                      TableScan [TS_9] (rows=1704 width=90)
+                                        default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_20]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_102] (rows=4635978 width=4)
+                                    Conds:RS_17._col0=RS_118._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_118]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_117] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_116] (rows=652 width=8)
+                                          predicate:(d_year = 2001)
+                                          TableScan [TS_6] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_17]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_101] (rows=4635978 width=4)
+                                        Conds:RS_115._col2=RS_107._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_107]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_106] (rows=14776 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_105] (rows=14776 width=268)
+                                              predicate:((cd_marital_status = 'U') and (cd_education_status = '2 yr Degree') and (cd_gender = 'M'))
+                                              TableScan [TS_3] (rows=1861800 width=268)
+                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_115]
+                                          PartitionCols:_col2
+                                          Select Operator [SEL_114] (rows=501690006 width=340)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                            Filter Operator [FIL_113] (rows=501690006 width=340)
+                                              predicate:(ss_cdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_cdemo_sk BETWEEN DynamicValue(RS_15_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_15_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_15_customer_demographics_cd_demo_sk_bloom_filter)))
+                                              TableScan [TS_0] (rows=575995635 width=340)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                              <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_112]
+                                                  Group By Operator [GBY_111] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_110]
+                                                      Group By Operator [GBY_109] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_108] (rows=14776 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_106]
 
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
index f78b2fa..6f2bb83 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
@@ -321,7 +321,7 @@ Stage-0
                       Group By Operator [GBY_314] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_313] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_312] (rows=38846 width=619)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_311] (rows=38846 width=548)
@@ -390,7 +390,7 @@ Stage-0
                       Group By Operator [GBY_321] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_320] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_319] (rows=53 width=615)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_318] (rows=53 width=548)
@@ -470,7 +470,7 @@ Stage-0
                       Group By Operator [GBY_298] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_297] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_296] (rows=822 width=617)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_295] (rows=822 width=548)
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
index 40810d4..e8cfe33 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
@@ -281,7 +281,7 @@ Stage-0
                       Group By Operator [GBY_234] (rows=564 width=446)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_233] (rows=531 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_231] (rows=10 width=439)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_230] (rows=10 width=452)
@@ -355,7 +355,7 @@ Stage-0
                       Group By Operator [GBY_240] (rows=564 width=446)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_239] (rows=531 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_237] (rows=394 width=435)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_236] (rows=394 width=335)
@@ -431,7 +431,7 @@ Stage-0
                       Group By Operator [GBY_228] (rows=564 width=446)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_227] (rows=531 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_225] (rows=127 width=436)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_224] (rows=127 width=379)
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
index 462eed8..9c82167 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
@@ -267,7 +267,7 @@ Stage-0
                       Group By Operator [GBY_448] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_447] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_446] (rows=38846 width=619)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_445] (rows=38846 width=436)
@@ -368,7 +368,7 @@ Stage-0
                       Group By Operator [GBY_462] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_461] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_460] (rows=53 width=615)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_459] (rows=53 width=436)
@@ -454,7 +454,7 @@ Stage-0
                       Group By Operator [GBY_428] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_427] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_426] (rows=822 width=617)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_425] (rows=822 width=436)
diff --git a/ql/src/test/results/clientpositive/perf/tez/query14.q.out b/ql/src/test/results/clientpositive/perf/tez/query14.q.out
index da6b74d..bf96850 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query14.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query14.q.out
@@ -314,7 +314,7 @@ Stage-0
                       Group By Operator [GBY_1190] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1189] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1187] (rows=40576 width=223)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1186] (rows=40576 width=244)
@@ -694,7 +694,7 @@ Stage-0
                       Group By Operator [GBY_1197] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1196] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1194] (rows=40576 width=219)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1193] (rows=40576 width=244)
@@ -885,7 +885,7 @@ Stage-0
                       Group By Operator [GBY_1183] (rows=304320 width=231)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
                         Top N Key Operator [TNK_1182] (rows=121728 width=221)
-                          keys:_col0, _col1, _col2, _col3, 0L,top n:100
+                          keys:_col0, _col1, _col2, _col3,top n:100
                           Select Operator [SEL_1180] (rows=40576 width=221)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
                             Filter Operator [FIL_1179] (rows=40576 width=244)
diff --git a/ql/src/test/results/clientpositive/perf/tez/query27.q.out b/ql/src/test/results/clientpositive/perf/tez/query27.q.out
index 62fbeda..cfc5823 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query27.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query27.q.out
@@ -87,83 +87,81 @@ Stage-0
                     PartitionCols:_col0, _col1, _col2
                     Group By Operator [GBY_29] (rows=13907934 width=570)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col2)","count(_col2)","sum(_col3)","count(_col3)","sum(_col4)","count(_col4)","sum(_col5)","count(_col5)"],keys:_col0, _col1, 0L
-                      Top N Key Operator [TNK_61] (rows=4635978 width=186)
-                        keys:_col0, _col1, 0L,top n:100
-                        Select Operator [SEL_27] (rows=4635978 width=186)
-                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                          Top N Key Operator [TNK_59] (rows=4635978 width=186)
-                            keys:_col13, _col11,top n:100
-                            Merge Join Operator [MERGEJOIN_105] (rows=4635978 width=186)
-                              Conds:RS_24._col1=RS_125._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col11","_col13"]
-                            <-Map 12 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_125]
-                                PartitionCols:_col0
-                                Select Operator [SEL_124] (rows=462000 width=104)
-                                  Output:["_col0","_col1"]
-                                  Filter Operator [FIL_123] (rows=462000 width=104)
-                                    predicate:i_item_sk is not null
-                                    TableScan [TS_12] (rows=462000 width=104)
-                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
-                            <-Reducer 4 [SIMPLE_EDGE]
-                              SHUFFLE [RS_24]
-                                PartitionCols:_col1
-                                Merge Join Operator [MERGEJOIN_104] (rows=4635978 width=90)
-                                  Conds:RS_21._col3=RS_122._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col11"]
-                                <-Map 11 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_122]
-                                    PartitionCols:_col0
-                                    Select Operator [SEL_121] (rows=209 width=90)
-                                      Output:["_col0","_col1"]
-                                      Filter Operator [FIL_120] (rows=209 width=90)
-                                        predicate:((s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC') and s_store_sk is not null)
-                                        TableScan [TS_9] (rows=1704 width=90)
-                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
-                                <-Reducer 3 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_21]
-                                    PartitionCols:_col3
-                                    Merge Join Operator [MERGEJOIN_103] (rows=4635978 width=4)
-                                      Conds:RS_18._col0=RS_119._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
-                                    <-Map 10 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_119]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_118] (rows=652 width=4)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_117] (rows=652 width=8)
-                                            predicate:((d_year = 2001) and d_date_sk is not null)
-                                            TableScan [TS_6] (rows=73049 width=8)
-                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
-                                    <-Reducer 2 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_18]
-                                        PartitionCols:_col0
-                                        Merge Join Operator [MERGEJOIN_102] (rows=4635978 width=4)
-                                          Conds:RS_116._col2=RS_108._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
-                                        <-Map 8 [SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_108]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_107] (rows=14776 width=4)
-                                              Output:["_col0"]
-                                              Filter Operator [FIL_106] (rows=14776 width=268)
-                                                predicate:((cd_marital_status = 'U') and (cd_education_status = '2 yr Degree') and (cd_gender = 'M') and cd_demo_sk is not null)
-                                                TableScan [TS_3] (rows=1861800 width=268)
-                                                  default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
-                                        <-Map 1 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_116]
-                                            PartitionCols:_col2
-                                            Select Operator [SEL_115] (rows=501690006 width=340)
-                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                              Filter Operator [FIL_114] (rows=501690006 width=340)
-                                                predicate:(ss_cdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_item_sk is not null and ss_cdemo_sk BETWEEN DynamicValue(RS_16_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_16_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_16_customer_demographics_cd_demo_sk_bloom_filter)))
-                                                TableScan [TS_0] (rows=575995635 width=340)
-                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
-                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_113]
-                                                    Group By Operator [GBY_112] (rows=1 width=12)
-                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_111]
-                                                        Group By Operator [GBY_110] (rows=1 width=12)
-                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_109] (rows=14776 width=4)
-                                                            Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_107]
+                      Select Operator [SEL_27] (rows=4635978 width=186)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                        Top N Key Operator [TNK_59] (rows=4635978 width=186)
+                          keys:_col13, _col11,top n:100
+                          Merge Join Operator [MERGEJOIN_105] (rows=4635978 width=186)
+                            Conds:RS_24._col1=RS_125._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col11","_col13"]
+                          <-Map 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_125]
+                              PartitionCols:_col0
+                              Select Operator [SEL_124] (rows=462000 width=104)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_123] (rows=462000 width=104)
+                                  predicate:i_item_sk is not null
+                                  TableScan [TS_12] (rows=462000 width=104)
+                                    default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_24]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_104] (rows=4635978 width=90)
+                                Conds:RS_21._col3=RS_122._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col11"]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_122]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_121] (rows=209 width=90)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_120] (rows=209 width=90)
+                                      predicate:((s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC') and s_store_sk is not null)
+                                      TableScan [TS_9] (rows=1704 width=90)
+                                        default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_21]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_103] (rows=4635978 width=4)
+                                    Conds:RS_18._col0=RS_119._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_119]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_118] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_117] (rows=652 width=8)
+                                          predicate:((d_year = 2001) and d_date_sk is not null)
+                                          TableScan [TS_6] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_18]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_102] (rows=4635978 width=4)
+                                        Conds:RS_116._col2=RS_108._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_108]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_107] (rows=14776 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_106] (rows=14776 width=268)
+                                              predicate:((cd_marital_status = 'U') and (cd_education_status = '2 yr Degree') and (cd_gender = 'M') and cd_demo_sk is not null)
+                                              TableScan [TS_3] (rows=1861800 width=268)
+                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_116]
+                                          PartitionCols:_col2
+                                          Select Operator [SEL_115] (rows=501690006 width=340)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                            Filter Operator [FIL_114] (rows=501690006 width=340)
+                                              predicate:(ss_cdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_item_sk is not null and ss_cdemo_sk BETWEEN DynamicValue(RS_16_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_16_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_16_customer_demographics_cd_demo_sk_bloom_filter)))
+                                              TableScan [TS_0] (rows=575995635 width=340)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                              <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_113]
+                                                  Group By Operator [GBY_112] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_111]
+                                                      Group By Operator [GBY_110] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_109] (rows=14776 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_107]
 
diff --git a/ql/src/test/results/clientpositive/perf/tez/query5.q.out b/ql/src/test/results/clientpositive/perf/tez/query5.q.out
index 34bbb51..af29b3e 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query5.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query5.q.out
@@ -321,7 +321,7 @@ Stage-0
                       Group By Operator [GBY_319] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_318] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_317] (rows=38846 width=619)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_316] (rows=38846 width=548)
@@ -392,7 +392,7 @@ Stage-0
                       Group By Operator [GBY_327] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_326] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_325] (rows=53 width=615)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_324] (rows=53 width=548)
@@ -474,7 +474,7 @@ Stage-0
                       Group By Operator [GBY_302] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_301] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_300] (rows=822 width=617)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_299] (rows=822 width=548)
diff --git a/ql/src/test/results/clientpositive/perf/tez/query77.q.out b/ql/src/test/results/clientpositive/perf/tez/query77.q.out
index 6b9c5b4..4efb3ee 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query77.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query77.q.out
@@ -285,7 +285,7 @@ Stage-0
                       Group By Operator [GBY_326] (rows=561 width=447)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_325] (rows=526 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_323] (rows=10 width=439)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_322] (rows=10 width=452)
@@ -359,7 +359,7 @@ Stage-0
                       Group By Operator [GBY_332] (rows=561 width=447)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_331] (rows=526 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_329] (rows=392 width=435)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_328] (rows=392 width=335)
@@ -454,7 +454,7 @@ Stage-0
                       Group By Operator [GBY_320] (rows=561 width=447)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_319] (rows=526 width=435)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_317] (rows=124 width=437)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Merge Join Operator [MERGEJOIN_316] (rows=124 width=379)
diff --git a/ql/src/test/results/clientpositive/perf/tez/query80.q.out b/ql/src/test/results/clientpositive/perf/tez/query80.q.out
index 30f77de..82e986d 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query80.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query80.q.out
@@ -267,7 +267,7 @@ Stage-0
                       Group By Operator [GBY_458] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_457] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_456] (rows=38846 width=619)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_455] (rows=38846 width=436)
@@ -372,7 +372,7 @@ Stage-0
                       Group By Operator [GBY_474] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_473] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_472] (rows=53 width=615)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_471] (rows=53 width=436)
@@ -462,7 +462,7 @@ Stage-0
                       Group By Operator [GBY_436] (rows=59581 width=627)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
                         Top N Key Operator [TNK_435] (rows=39721 width=618)
-                          keys:_col0, _col1, 0L,top n:100
+                          keys:_col0, _col1,top n:100
                           Select Operator [SEL_434] (rows=822 width=617)
                             Output:["_col0","_col1","_col2","_col3","_col4"]
                             Group By Operator [GBY_433] (rows=822 width=436)