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 2018/07/19 21:24:17 UTC

[04/13] hive git commit: HIVE-17896: TopNKey: Create a standalone vectorizable TopNKey operator (Teddy Choi, reviewed by Jesus Camacho Rodriguez)

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query66.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query66.q.out b/ql/src/test/results/clientpositive/perf/tez/query66.q.out
index 97c1636..1d32a46 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query66.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query66.q.out
@@ -461,152 +461,156 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 9 vectorized
-      File Output Operator [FS_162]
-        Select Operator [SEL_161] (rows=100 width=135)
+      File Output Operator [FS_166]
+        Select Operator [SEL_165] (rows=100 width=135)
           Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41","_col42","_col43"]
-          Limit [LIM_160] (rows=100 width=135)
+          Limit [LIM_164] (rows=100 width=135)
             Number of rows:100
-            Select Operator [SEL_159] (rows=158120068 width=135)
+            Select Operator [SEL_163] (rows=158120068 width=135)
               Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
             <-Reducer 8 [SIMPLE_EDGE] vectorized
-              SHUFFLE [RS_158]
-                Group By Operator [GBY_157] (rows=158120068 width=135)
+              SHUFFLE [RS_162]
+                Group By Operator [GBY_161] (rows=158120068 width=135)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)","sum(VALUE._col24)","sum(VALUE._col25)","sum(VALUE._col26)","sum(VALUE._col27)","sum(VALUE._col28)","sum(VALUE._col29)
 ","sum(VALUE._col30)","sum(VALUE._col31)","sum(VALUE._col32)","sum(VALUE._col33)","sum(VALUE._col34)","sum(VALUE._col35)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
                 <-Union 7 [SIMPLE_EDGE]
                   <-Reducer 15 [CONTAINS] vectorized
-                    Reduce Output Operator [RS_169]
+                    Reduce Output Operator [RS_174]
                       PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
-                      Group By Operator [GBY_168] (rows=316240137 width=135)
+                      Group By Operator [GBY_173] (rows=316240137 width=135)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)","sum(_col30)","sum(_col31)","sum(_col32)","sum(_col33)","sum(_col34)","sum(_col35)","sum(_col36)","sum(_col37)","sum(_col38)","sum(_col39)","sum(_col40)","sum(_col41)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
-                        Select Operator [SEL_167] (rows=316240137 width=135)
-                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
-                          Group By Operator [GBY_166] (rows=210822976 width=135)
-                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
-                          <-Reducer 14 [SIMPLE_EDGE]
-                            SHUFFLE [RS_63]
-                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
-                              Group By Operator [GBY_62] (rows=421645953 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
-                                Select Operator [SEL_60] (rows=421645953 width=135)
-                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
-                                  Merge Join Operator [MERGEJOIN_123] (rows=421645953 width=135)
-                                    Conds:RS_57._col3=RS_152._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
-                                  <-Map 18 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_152]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_150] (rows=27 width=1029)
-                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                        Filter Operator [FIL_149] (rows=27 width=1029)
-                                          predicate:w_warehouse_sk is not null
-                                          TableScan [TS_12] (rows=27 width=1029)
-                                            default@warehouse,warehouse,Tbl:COMPLETE,Col:NONE,Output:["w_warehouse_sk","w_warehouse_name","w_warehouse_sq_ft","w_city","w_county","w_state","w_country"]
-                                  <-Reducer 13 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_57]
-                                      PartitionCols:_col3
-                                      Merge Join Operator [MERGEJOIN_122] (rows=383314495 width=135)
-                                        Conds:RS_54._col2=RS_148._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
-                                      <-Map 17 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_148]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_146] (rows=1 width=0)
-                                            Output:["_col0"]
-                                            Filter Operator [FIL_145] (rows=1 width=0)
-                                              predicate:((sm_carrier) IN ('DIAMOND', 'AIRBORNE') and sm_ship_mode_sk is not null)
-                                              TableScan [TS_9] (rows=1 width=0)
-                                                default@ship_mode,ship_mode,Tbl:PARTIAL,Col:NONE,Output:["sm_ship_mode_sk","sm_carrier"]
-                                      <-Reducer 12 [SIMPLE_EDGE]
-                                        SHUFFLE [RS_54]
-                                          PartitionCols:_col2
-                                          Merge Join Operator [MERGEJOIN_121] (rows=348467716 width=135)
-                                            Conds:RS_51._col0=RS_144._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
-                                          <-Map 16 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_144]
-                                              PartitionCols:_col0
-                                              Select Operator [SEL_142] (rows=36524 width=1119)
-                                                Output:["_col0","_col2"]
-                                                Filter Operator [FIL_141] (rows=36524 width=1119)
-                                                  predicate:((d_year = 2002) and d_date_sk is not null)
-                                                  TableScan [TS_6] (rows=73049 width=1119)
-                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
-                                          <-Reducer 11 [SIMPLE_EDGE]
-                                            SHUFFLE [RS_51]
-                                              PartitionCols:_col0
-                                              Merge Join Operator [MERGEJOIN_120] (rows=316788826 width=135)
-                                                Conds:RS_165._col1=RS_140._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
-                                              <-Map 10 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_140]
-                                                  PartitionCols:_col0
-                                                  Select Operator [SEL_138] (rows=9600 width=471)
-                                                    Output:["_col0"]
-                                                    Filter Operator [FIL_137] (rows=9600 width=471)
-                                                      predicate:(t_time BETWEEN 49530 AND 78330 and t_time_sk is not null)
-                                                      TableScan [TS_3] (rows=86400 width=471)
-                                                        default@time_dim,time_dim,Tbl:COMPLETE,Col:NONE,Output:["t_time_sk","t_time"]
-                                              <-Map 19 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_165]
-                                                  PartitionCols:_col1
-                                                  Select Operator [SEL_164] (rows=287989836 width=135)
-                                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                                    Filter Operator [FIL_163] (rows=287989836 width=135)
-                                                      predicate:(cs_ship_mode_sk is not null and cs_sold_date_sk is not null and cs_sold_time_sk is not null and cs_warehouse_sk is not null)
-                                                      TableScan [TS_33] (rows=287989836 width=135)
-                                                        default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_sold_time_sk","cs_ship_mode_sk","cs_warehouse_sk","cs_quantity","cs_ext_sales_price","cs_net_paid_inc_ship_tax"]
+                        Top N Key Operator [TNK_172] (rows=316240137 width=135)
+                          keys:_col0, _col1, _col2, _col3, _col4, _col5,sort order:++++++,top n:100
+                          Select Operator [SEL_171] (rows=316240137 width=135)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+                            Group By Operator [GBY_170] (rows=210822976 width=135)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Reducer 14 [SIMPLE_EDGE]
+                              SHUFFLE [RS_63]
+                                PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                Group By Operator [GBY_62] (rows=421645953 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                  Select Operator [SEL_60] (rows=421645953 width=135)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
+                                    Merge Join Operator [MERGEJOIN_124] (rows=421645953 width=135)
+                                      Conds:RS_57._col3=RS_155._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
+                                    <-Map 18 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_155]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_153] (rows=27 width=1029)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                          Filter Operator [FIL_152] (rows=27 width=1029)
+                                            predicate:w_warehouse_sk is not null
+                                            TableScan [TS_12] (rows=27 width=1029)
+                                              default@warehouse,warehouse,Tbl:COMPLETE,Col:NONE,Output:["w_warehouse_sk","w_warehouse_name","w_warehouse_sq_ft","w_city","w_county","w_state","w_country"]
+                                    <-Reducer 13 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_57]
+                                        PartitionCols:_col3
+                                        Merge Join Operator [MERGEJOIN_123] (rows=383314495 width=135)
+                                          Conds:RS_54._col2=RS_151._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
+                                        <-Map 17 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_151]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_149] (rows=1 width=0)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_148] (rows=1 width=0)
+                                                predicate:((sm_carrier) IN ('DIAMOND', 'AIRBORNE') and sm_ship_mode_sk is not null)
+                                                TableScan [TS_9] (rows=1 width=0)
+                                                  default@ship_mode,ship_mode,Tbl:PARTIAL,Col:NONE,Output:["sm_ship_mode_sk","sm_carrier"]
+                                        <-Reducer 12 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_54]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_122] (rows=348467716 width=135)
+                                              Conds:RS_51._col0=RS_147._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
+                                            <-Map 16 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_147]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_145] (rows=36524 width=1119)
+                                                  Output:["_col0","_col2"]
+                                                  Filter Operator [FIL_144] (rows=36524 width=1119)
+                                                    predicate:((d_year = 2002) and d_date_sk is not null)
+                                                    TableScan [TS_6] (rows=73049 width=1119)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Reducer 11 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_51]
+                                                PartitionCols:_col0
+                                                Merge Join Operator [MERGEJOIN_121] (rows=316788826 width=135)
+                                                  Conds:RS_169._col1=RS_143._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
+                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_143]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_141] (rows=9600 width=471)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_140] (rows=9600 width=471)
+                                                        predicate:(t_time BETWEEN 49530 AND 78330 and t_time_sk is not null)
+                                                        TableScan [TS_3] (rows=86400 width=471)
+                                                          default@time_dim,time_dim,Tbl:COMPLETE,Col:NONE,Output:["t_time_sk","t_time"]
+                                                <-Map 19 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_169]
+                                                    PartitionCols:_col1
+                                                    Select Operator [SEL_168] (rows=287989836 width=135)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                      Filter Operator [FIL_167] (rows=287989836 width=135)
+                                                        predicate:(cs_ship_mode_sk is not null and cs_sold_date_sk is not null and cs_sold_time_sk is not null and cs_warehouse_sk is not null)
+                                                        TableScan [TS_33] (rows=287989836 width=135)
+                                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_sold_time_sk","cs_ship_mode_sk","cs_warehouse_sk","cs_quantity","cs_ext_sales_price","cs_net_paid_inc_ship_tax"]
                   <-Reducer 6 [CONTAINS] vectorized
-                    Reduce Output Operator [RS_156]
+                    Reduce Output Operator [RS_160]
                       PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
-                      Group By Operator [GBY_155] (rows=316240137 width=135)
+                      Group By Operator [GBY_159] (rows=316240137 width=135)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)","sum(_col30)","sum(_col31)","sum(_col32)","sum(_col33)","sum(_col34)","sum(_col35)","sum(_col36)","sum(_col37)","sum(_col38)","sum(_col39)","sum(_col40)","sum(_col41)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
-                        Select Operator [SEL_154] (rows=316240137 width=135)
-                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
-                          Group By Operator [GBY_153] (rows=105417161 width=135)
-                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
-                          <-Reducer 5 [SIMPLE_EDGE]
-                            SHUFFLE [RS_30]
-                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
-                              Group By Operator [GBY_29] (rows=210834322 width=135)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
-                                Select Operator [SEL_27] (rows=210834322 width=135)
-                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
-                                  Merge Join Operator [MERGEJOIN_119] (rows=210834322 width=135)
-                                    Conds:RS_24._col3=RS_151._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
-                                  <-Map 18 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_151]
-                                      PartitionCols:_col0
-                                       Please refer to the previous Select Operator [SEL_150]
-                                  <-Reducer 4 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_24]
-                                      PartitionCols:_col3
-                                      Merge Join Operator [MERGEJOIN_118] (rows=191667562 width=135)
-                                        Conds:RS_21._col2=RS_147._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
-                                      <-Map 17 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_147]
-                                          PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_146]
-                                      <-Reducer 3 [SIMPLE_EDGE]
-                                        SHUFFLE [RS_21]
-                                          PartitionCols:_col2
-                                          Merge Join Operator [MERGEJOIN_117] (rows=174243235 width=135)
-                                            Conds:RS_18._col0=RS_143._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
-                                          <-Map 16 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_143]
-                                              PartitionCols:_col0
-                                               Please refer to the previous Select Operator [SEL_142]
-                                          <-Reducer 2 [SIMPLE_EDGE]
-                                            SHUFFLE [RS_18]
-                                              PartitionCols:_col0
-                                              Merge Join Operator [MERGEJOIN_116] (rows=158402938 width=135)
-                                                Conds:RS_136._col1=RS_139._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
-                                              <-Map 10 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_139]
-                                                  PartitionCols:_col0
-                                                   Please refer to the previous Select Operator [SEL_138]
-                                              <-Map 1 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_136]
-                                                  PartitionCols:_col1
-                                                  Select Operator [SEL_135] (rows=144002668 width=135)
-                                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                                                    Filter Operator [FIL_134] (rows=144002668 width=135)
-                                                      predicate:(ws_ship_mode_sk is not null and ws_sold_date_sk is not null and ws_sold_time_sk is not null and ws_warehouse_sk is not null)
-                                                      TableScan [TS_0] (rows=144002668 width=135)
-                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_sold_time_sk","ws_ship_mode_sk","ws_warehouse_sk","ws_quantity","ws_sales_price","ws_net_paid_inc_tax"]
+                        Top N Key Operator [TNK_158] (rows=316240137 width=135)
+                          keys:_col0, _col1, _col2, _col3, _col4, _col5,sort order:++++++,top n:100
+                          Select Operator [SEL_157] (rows=316240137 width=135)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+                            Group By Operator [GBY_156] (rows=105417161 width=135)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Reducer 5 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                Group By Operator [GBY_29] (rows=210834322 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                  Select Operator [SEL_27] (rows=210834322 width=135)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
+                                    Merge Join Operator [MERGEJOIN_120] (rows=210834322 width=135)
+                                      Conds:RS_24._col3=RS_154._col0(Inner),Output:["_col4","_col5","_col6","_col11","_col15","_col16","_col17","_col18","_col19","_col20"]
+                                    <-Map 18 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_154]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_153]
+                                    <-Reducer 4 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_24]
+                                        PartitionCols:_col3
+                                        Merge Join Operator [MERGEJOIN_119] (rows=191667562 width=135)
+                                          Conds:RS_21._col2=RS_150._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col11"]
+                                        <-Map 17 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_150]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_149]
+                                        <-Reducer 3 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_21]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_118] (rows=174243235 width=135)
+                                              Conds:RS_18._col0=RS_146._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col11"]
+                                            <-Map 16 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_146]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_145]
+                                            <-Reducer 2 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_18]
+                                                PartitionCols:_col0
+                                                Merge Join Operator [MERGEJOIN_117] (rows=158402938 width=135)
+                                                  Conds:RS_139._col1=RS_142._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6"]
+                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_142]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_141]
+                                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_139]
+                                                    PartitionCols:_col1
+                                                    Select Operator [SEL_138] (rows=144002668 width=135)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                      Filter Operator [FIL_137] (rows=144002668 width=135)
+                                                        predicate:(ws_ship_mode_sk is not null and ws_sold_date_sk is not null and ws_sold_time_sk is not null and ws_warehouse_sk is not null)
+                                                        TableScan [TS_0] (rows=144002668 width=135)
+                                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_sold_time_sk","ws_ship_mode_sk","ws_warehouse_sk","ws_quantity","ws_sales_price","ws_net_paid_inc_tax"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query69.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query69.q.out b/ql/src/test/results/clientpositive/perf/tez/query69.q.out
index 1cb22f7..1c6db5b 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query69.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query69.q.out
@@ -110,153 +110,155 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_146]
-        Limit [LIM_145] (rows=100 width=88)
+      File Output Operator [FS_147]
+        Limit [LIM_146] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_144] (rows=191662559 width=88)
+          Select Operator [SEL_145] (rows=191662559 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_143]
-              Select Operator [SEL_142] (rows=191662559 width=88)
+            SHUFFLE [RS_144]
+              Select Operator [SEL_143] (rows=191662559 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col6"]
-                Group By Operator [GBY_141] (rows=191662559 width=88)
+                Group By Operator [GBY_142] (rows=191662559 width=88)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
                 <-Reducer 5 [SIMPLE_EDGE]
                   SHUFFLE [RS_67]
                     PartitionCols:_col0, _col1, _col2, _col3, _col4
                     Group By Operator [GBY_66] (rows=383325119 width=88)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count()"],keys:_col6, _col7, _col8, _col9, _col10
-                      Select Operator [SEL_65] (rows=383325119 width=88)
-                        Output:["_col6","_col7","_col8","_col9","_col10"]
-                        Filter Operator [FIL_64] (rows=383325119 width=88)
-                          predicate:_col14 is null
-                          Merge Join Operator [MERGEJOIN_111] (rows=766650239 width=88)
-                            Conds:RS_61._col0=RS_140._col0(Left Outer),Output:["_col6","_col7","_col8","_col9","_col10","_col14"]
-                          <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
-                            FORWARD [RS_140]
-                              PartitionCols:_col0
-                              Select Operator [SEL_139] (rows=158394413 width=135)
-                                Output:["_col0","_col1"]
-                                Group By Operator [GBY_138] (rows=158394413 width=135)
-                                  Output:["_col0"],keys:KEY._col0
-                                <-Reducer 15 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_58]
-                                    PartitionCols:_col0
-                                    Group By Operator [GBY_57] (rows=316788826 width=135)
-                                      Output:["_col0"],keys:_col1
-                                      Merge Join Operator [MERGEJOIN_109] (rows=316788826 width=135)
-                                        Conds:RS_137._col0=RS_128._col0(Inner),Output:["_col1"]
-                                      <-Map 12 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_128]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_125] (rows=4058 width=1119)
-                                            Output:["_col0"]
-                                            Filter Operator [FIL_124] (rows=4058 width=1119)
-                                              predicate:((d_year = 1999) and d_date_sk is not null and d_moy BETWEEN 1 AND 3)
-                                              TableScan [TS_12] (rows=73049 width=1119)
-                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
-                                      <-Map 18 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_137]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_136] (rows=287989836 width=135)
-                                            Output:["_col0","_col1"]
-                                            Filter Operator [FIL_135] (rows=287989836 width=135)
-                                              predicate:(cs_ship_customer_sk is not null and cs_sold_date_sk is not null)
-                                              TableScan [TS_47] (rows=287989836 width=135)
-                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_ship_customer_sk"]
-                          <-Reducer 4 [ONE_TO_ONE_EDGE]
-                            FORWARD [RS_61]
-                              PartitionCols:_col0
-                              Select Operator [SEL_46] (rows=696954748 width=88)
-                                Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
-                                Filter Operator [FIL_45] (rows=696954748 width=88)
-                                  predicate:_col12 is null
-                                  Merge Join Operator [MERGEJOIN_110] (rows=1393909496 width=88)
-                                    Conds:RS_41._col0=RS_42._col0(Left Semi),RS_41._col0=RS_134._col0(Left Outer),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col12"]
-                                  <-Reducer 11 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_42]
-                                      PartitionCols:_col0
-                                      Group By Operator [GBY_40] (rows=633595212 width=88)
-                                        Output:["_col0"],keys:_col0
-                                        Select Operator [SEL_18] (rows=633595212 width=88)
-                                          Output:["_col0"]
-                                          Merge Join Operator [MERGEJOIN_107] (rows=633595212 width=88)
-                                            Conds:RS_123._col0=RS_126._col0(Inner),Output:["_col1"]
-                                          <-Map 12 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_126]
-                                              PartitionCols:_col0
-                                               Please refer to the previous Select Operator [SEL_125]
-                                          <-Map 10 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_123]
-                                              PartitionCols:_col0
-                                              Select Operator [SEL_122] (rows=575995635 width=88)
-                                                Output:["_col0","_col1"]
-                                                Filter Operator [FIL_121] (rows=575995635 width=88)
-                                                  predicate:(ss_customer_sk is not null and ss_sold_date_sk is not null)
-                                                  TableScan [TS_9] (rows=575995635 width=88)
-                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_customer_sk"]
-                                  <-Reducer 14 [ONE_TO_ONE_EDGE] vectorized
-                                    FORWARD [RS_134]
+                      Top N Key Operator [TNK_105] (rows=383325119 width=88)
+                        keys:_col6, _col7, _col8, _col9, _col10,sort order:+++++,top n:100
+                        Select Operator [SEL_65] (rows=383325119 width=88)
+                          Output:["_col6","_col7","_col8","_col9","_col10"]
+                          Filter Operator [FIL_64] (rows=383325119 width=88)
+                            predicate:_col14 is null
+                            Merge Join Operator [MERGEJOIN_112] (rows=766650239 width=88)
+                              Conds:RS_61._col0=RS_141._col0(Left Outer),Output:["_col6","_col7","_col8","_col9","_col10","_col14"]
+                            <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_141]
+                                PartitionCols:_col0
+                                Select Operator [SEL_140] (rows=158394413 width=135)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_139] (rows=158394413 width=135)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_58]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_133] (rows=79201469 width=135)
-                                        Output:["_col0","_col1"]
-                                        Group By Operator [GBY_132] (rows=79201469 width=135)
-                                          Output:["_col0"],keys:KEY._col0
-                                        <-Reducer 13 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_30]
+                                      Group By Operator [GBY_57] (rows=316788826 width=135)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_110] (rows=316788826 width=135)
+                                          Conds:RS_138._col0=RS_129._col0(Inner),Output:["_col1"]
+                                        <-Map 12 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_129]
                                             PartitionCols:_col0
-                                            Group By Operator [GBY_29] (rows=158402938 width=135)
-                                              Output:["_col0"],keys:_col1
-                                              Merge Join Operator [MERGEJOIN_108] (rows=158402938 width=135)
-                                                Conds:RS_131._col0=RS_127._col0(Inner),Output:["_col1"]
-                                              <-Map 12 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_127]
-                                                  PartitionCols:_col0
-                                                   Please refer to the previous Select Operator [SEL_125]
-                                              <-Map 17 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_131]
-                                                  PartitionCols:_col0
-                                                  Select Operator [SEL_130] (rows=144002668 width=135)
-                                                    Output:["_col0","_col1"]
-                                                    Filter Operator [FIL_129] (rows=144002668 width=135)
-                                                      predicate:(ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
-                                                      TableScan [TS_19] (rows=144002668 width=135)
-                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
-                                  <-Reducer 3 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_41]
-                                      PartitionCols:_col0
-                                      Merge Join Operator [MERGEJOIN_106] (rows=96800003 width=860)
-                                        Conds:RS_36._col1=RS_120._col0(Inner),Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
-                                      <-Map 9 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_120]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_119] (rows=1861800 width=385)
-                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                            Filter Operator [FIL_118] (rows=1861800 width=385)
-                                              predicate:cd_demo_sk is not null
-                                              TableScan [TS_6] (rows=1861800 width=385)
-                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status","cd_purchase_estimate","cd_credit_rating"]
-                                      <-Reducer 2 [SIMPLE_EDGE]
-                                        SHUFFLE [RS_36]
-                                          PartitionCols:_col1
-                                          Merge Join Operator [MERGEJOIN_105] (rows=88000001 width=860)
-                                            Conds:RS_114._col2=RS_117._col0(Inner),Output:["_col0","_col1"]
-                                          <-Map 1 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_114]
-                                              PartitionCols:_col2
-                                              Select Operator [SEL_113] (rows=80000000 width=860)
-                                                Output:["_col0","_col1","_col2"]
-                                                Filter Operator [FIL_112] (rows=80000000 width=860)
-                                                  predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_customer_sk is not null)
-                                                  TableScan [TS_0] (rows=80000000 width=860)
-                                                    default@customer,c,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk"]
-                                          <-Map 8 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_117]
+                                            Select Operator [SEL_126] (rows=4058 width=1119)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_125] (rows=4058 width=1119)
+                                                predicate:((d_year = 1999) and d_date_sk is not null and d_moy BETWEEN 1 AND 3)
+                                                TableScan [TS_12] (rows=73049 width=1119)
+                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                        <-Map 18 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_138]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_137] (rows=287989836 width=135)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_136] (rows=287989836 width=135)
+                                                predicate:(cs_ship_customer_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_47] (rows=287989836 width=135)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_ship_customer_sk"]
+                            <-Reducer 4 [ONE_TO_ONE_EDGE]
+                              FORWARD [RS_61]
+                                PartitionCols:_col0
+                                Select Operator [SEL_46] (rows=696954748 width=88)
+                                  Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
+                                  Filter Operator [FIL_45] (rows=696954748 width=88)
+                                    predicate:_col12 is null
+                                    Merge Join Operator [MERGEJOIN_111] (rows=1393909496 width=88)
+                                      Conds:RS_41._col0=RS_42._col0(Left Semi),RS_41._col0=RS_135._col0(Left Outer),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col12"]
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_42]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_40] (rows=633595212 width=88)
+                                          Output:["_col0"],keys:_col0
+                                          Select Operator [SEL_18] (rows=633595212 width=88)
+                                            Output:["_col0"]
+                                            Merge Join Operator [MERGEJOIN_108] (rows=633595212 width=88)
+                                              Conds:RS_124._col0=RS_127._col0(Inner),Output:["_col1"]
+                                            <-Map 12 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_127]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_126]
+                                            <-Map 10 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_124]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_123] (rows=575995635 width=88)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_122] (rows=575995635 width=88)
+                                                    predicate:(ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                    TableScan [TS_9] (rows=575995635 width=88)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                    <-Reducer 14 [ONE_TO_ONE_EDGE] vectorized
+                                      FORWARD [RS_135]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_134] (rows=79201469 width=135)
+                                          Output:["_col0","_col1"]
+                                          Group By Operator [GBY_133] (rows=79201469 width=135)
+                                            Output:["_col0"],keys:KEY._col0
+                                          <-Reducer 13 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_30]
                                               PartitionCols:_col0
-                                              Select Operator [SEL_116] (rows=20000000 width=1014)
-                                                Output:["_col0"]
-                                                Filter Operator [FIL_115] (rows=20000000 width=1014)
-                                                  predicate:((ca_state) IN ('CO', 'IL', 'MN') and ca_address_sk is not null)
-                                                  TableScan [TS_3] (rows=40000000 width=1014)
-                                                    default@customer_address,ca,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
+                                              Group By Operator [GBY_29] (rows=158402938 width=135)
+                                                Output:["_col0"],keys:_col1
+                                                Merge Join Operator [MERGEJOIN_109] (rows=158402938 width=135)
+                                                  Conds:RS_132._col0=RS_128._col0(Inner),Output:["_col1"]
+                                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_128]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_126]
+                                                <-Map 17 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_132]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_131] (rows=144002668 width=135)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_130] (rows=144002668 width=135)
+                                                        predicate:(ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                        TableScan [TS_19] (rows=144002668 width=135)
+                                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_41]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_107] (rows=96800003 width=860)
+                                          Conds:RS_36._col1=RS_121._col0(Inner),Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
+                                        <-Map 9 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_121]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_120] (rows=1861800 width=385)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_119] (rows=1861800 width=385)
+                                                predicate:cd_demo_sk is not null
+                                                TableScan [TS_6] (rows=1861800 width=385)
+                                                  default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status","cd_purchase_estimate","cd_credit_rating"]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_36]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_106] (rows=88000001 width=860)
+                                              Conds:RS_115._col2=RS_118._col0(Inner),Output:["_col0","_col1"]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_115]
+                                                PartitionCols:_col2
+                                                Select Operator [SEL_114] (rows=80000000 width=860)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_113] (rows=80000000 width=860)
+                                                    predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_customer_sk is not null)
+                                                    TableScan [TS_0] (rows=80000000 width=860)
+                                                      default@customer,c,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk"]
+                                            <-Map 8 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_118]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_117] (rows=20000000 width=1014)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_116] (rows=20000000 width=1014)
+                                                    predicate:((ca_state) IN ('CO', 'IL', 'MN') and ca_address_sk is not null)
+                                                    TableScan [TS_3] (rows=40000000 width=1014)
+                                                      default@customer_address,ca,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query7.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query7.q.out b/ql/src/test/results/clientpositive/perf/tez/query7.q.out
index 557594f..512d4d5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query7.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query7.q.out
@@ -53,82 +53,84 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_79]
-        Limit [LIM_78] (rows=100 width=88)
+      File Output Operator [FS_80]
+        Limit [LIM_79] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_77] (rows=421657640 width=88)
+          Select Operator [SEL_78] (rows=421657640 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_76]
-              Select Operator [SEL_75] (rows=421657640 width=88)
+            SHUFFLE [RS_77]
+              Select Operator [SEL_76] (rows=421657640 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4"]
-                Group By Operator [GBY_74] (rows=421657640 width=88)
+                Group By Operator [GBY_75] (rows=421657640 width=88)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)"],keys:KEY._col0
                 <-Reducer 5 [SIMPLE_EDGE]
                   SHUFFLE [RS_29]
                     PartitionCols:_col0
                     Group By Operator [GBY_28] (rows=843315281 width=88)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col4)","count(_col4)","sum(_col5)","count(_col5)","sum(_col7)","count(_col7)","sum(_col6)","count(_col6)"],keys:_col18
-                      Merge Join Operator [MERGEJOIN_58] (rows=843315281 width=88)
-                        Conds:RS_24._col1=RS_73._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col18"]
-                      <-Map 11 [SIMPLE_EDGE] vectorized
-                        SHUFFLE [RS_73]
-                          PartitionCols:_col0
-                          Select Operator [SEL_72] (rows=462000 width=1436)
-                            Output:["_col0","_col1"]
-                            Filter Operator [FIL_71] (rows=462000 width=1436)
-                              predicate:i_item_sk is not null
-                              TableScan [TS_12] (rows=462000 width=1436)
-                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id"]
-                      <-Reducer 4 [SIMPLE_EDGE]
-                        SHUFFLE [RS_24]
-                          PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_57] (rows=766650239 width=88)
-                            Conds:RS_21._col3=RS_70._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7"]
-                          <-Map 10 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_70]
-                              PartitionCols:_col0
-                              Select Operator [SEL_69] (rows=2300 width=1179)
-                                Output:["_col0"]
-                                Filter Operator [FIL_68] (rows=2300 width=1179)
-                                  predicate:(((p_channel_email = 'N') or (p_channel_event = 'N')) and p_promo_sk is not null)
-                                  TableScan [TS_9] (rows=2300 width=1179)
-                                    default@promotion,promotion,Tbl:COMPLETE,Col:NONE,Output:["p_promo_sk","p_channel_email","p_channel_event"]
-                          <-Reducer 3 [SIMPLE_EDGE]
-                            SHUFFLE [RS_21]
-                              PartitionCols:_col3
-                              Merge Join Operator [MERGEJOIN_56] (rows=696954748 width=88)
-                                Conds:RS_18._col0=RS_67._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
-                              <-Map 9 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_67]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_66] (rows=36524 width=1119)
-                                    Output:["_col0"]
-                                    Filter Operator [FIL_65] (rows=36524 width=1119)
-                                      predicate:((d_year = 1998) and d_date_sk is not null)
-                                      TableScan [TS_6] (rows=73049 width=1119)
-                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
-                              <-Reducer 2 [SIMPLE_EDGE]
-                                SHUFFLE [RS_18]
-                                  PartitionCols:_col0
-                                  Merge Join Operator [MERGEJOIN_55] (rows=633595212 width=88)
-                                    Conds:RS_61._col2=RS_64._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
-                                  <-Map 1 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_61]
-                                      PartitionCols:_col2
-                                      Select Operator [SEL_60] (rows=575995635 width=88)
-                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                        Filter Operator [FIL_59] (rows=575995635 width=88)
-                                          predicate:(ss_cdemo_sk is not null and ss_item_sk is not null and ss_promo_sk is not null and ss_sold_date_sk is not null)
-                                          TableScan [TS_0] (rows=575995635 width=88)
-                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_promo_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
-                                  <-Map 8 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_64]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_63] (rows=232725 width=385)
-                                        Output:["_col0"]
-                                        Filter Operator [FIL_62] (rows=232725 width=385)
-                                          predicate:((cd_education_status = 'Primary') and (cd_gender = 'F') and (cd_marital_status = 'W') and cd_demo_sk is not null)
-                                          TableScan [TS_3] (rows=1861800 width=385)
-                                            default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                      Top N Key Operator [TNK_55] (rows=843315281 width=88)
+                        keys:_col18,sort order:+,top n:100
+                        Merge Join Operator [MERGEJOIN_59] (rows=843315281 width=88)
+                          Conds:RS_24._col1=RS_74._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col18"]
+                        <-Map 11 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_74]
+                            PartitionCols:_col0
+                            Select Operator [SEL_73] (rows=462000 width=1436)
+                              Output:["_col0","_col1"]
+                              Filter Operator [FIL_72] (rows=462000 width=1436)
+                                predicate:i_item_sk is not null
+                                TableScan [TS_12] (rows=462000 width=1436)
+                                  default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id"]
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_24]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_58] (rows=766650239 width=88)
+                              Conds:RS_21._col3=RS_71._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7"]
+                            <-Map 10 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_71]
+                                PartitionCols:_col0
+                                Select Operator [SEL_70] (rows=2300 width=1179)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_69] (rows=2300 width=1179)
+                                    predicate:(((p_channel_email = 'N') or (p_channel_event = 'N')) and p_promo_sk is not null)
+                                    TableScan [TS_9] (rows=2300 width=1179)
+                                      default@promotion,promotion,Tbl:COMPLETE,Col:NONE,Output:["p_promo_sk","p_channel_email","p_channel_event"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_21]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_57] (rows=696954748 width=88)
+                                  Conds:RS_18._col0=RS_68._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                <-Map 9 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_68]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_67] (rows=36524 width=1119)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_66] (rows=36524 width=1119)
+                                        predicate:((d_year = 1998) and d_date_sk is not null)
+                                        TableScan [TS_6] (rows=73049 width=1119)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_18]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_56] (rows=633595212 width=88)
+                                      Conds:RS_62._col2=RS_65._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_62]
+                                        PartitionCols:_col2
+                                        Select Operator [SEL_61] (rows=575995635 width=88)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_60] (rows=575995635 width=88)
+                                            predicate:(ss_cdemo_sk is not null and ss_item_sk is not null and ss_promo_sk is not null and ss_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=575995635 width=88)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_promo_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_65]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_64] (rows=232725 width=385)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_63] (rows=232725 width=385)
+                                            predicate:((cd_education_status = 'Primary') and (cd_gender = 'F') and (cd_marital_status = 'W') and cd_demo_sk is not null)
+                                            TableScan [TS_3] (rows=1861800 width=385)
+                                              default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:NONE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]