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:21 UTC

[08/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/query15.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query15.q.out b/ql/src/test/results/clientpositive/perf/tez/query15.q.out
index e4e0199..2f9f704 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query15.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query15.q.out
@@ -50,70 +50,72 @@ Stage-0
     limit:100
     Stage-1
       Reducer 5 vectorized
-      File Output Operator [FS_63]
-        Limit [LIM_62] (rows=100 width=135)
+      File Output Operator [FS_64]
+        Limit [LIM_63] (rows=100 width=135)
           Number of rows:100
-          Select Operator [SEL_61] (rows=174233858 width=135)
+          Select Operator [SEL_62] (rows=174233858 width=135)
             Output:["_col0","_col1"]
           <-Reducer 4 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_60]
-              Group By Operator [GBY_59] (rows=174233858 width=135)
+            SHUFFLE [RS_61]
+              Group By Operator [GBY_60] (rows=174233858 width=135)
                 Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
               <-Reducer 3 [SIMPLE_EDGE]
                 SHUFFLE [RS_25]
                   PartitionCols:_col0
                   Group By Operator [GBY_24] (rows=348467716 width=135)
                     Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col4
-                    Select Operator [SEL_23] (rows=348467716 width=135)
-                      Output:["_col4","_col7"]
-                      Filter Operator [FIL_22] (rows=348467716 width=135)
-                        predicate:((_col3) IN ('CA', 'WA', 'GA') or (_col7 > 500) or (substr(_col4, 1, 5)) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792'))
-                        Merge Join Operator [MERGEJOIN_46] (rows=348467716 width=135)
-                          Conds:RS_19._col0=RS_20._col1(Inner),Output:["_col3","_col4","_col7"]
-                        <-Reducer 2 [SIMPLE_EDGE]
-                          SHUFFLE [RS_19]
-                            PartitionCols:_col0
-                            Merge Join Operator [MERGEJOIN_44] (rows=88000001 width=860)
-                              Conds:RS_49._col1=RS_52._col0(Inner),Output:["_col0","_col3","_col4"]
-                            <-Map 1 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_49]
-                                PartitionCols:_col1
-                                Select Operator [SEL_48] (rows=80000000 width=860)
-                                  Output:["_col0","_col1"]
-                                  Filter Operator [FIL_47] (rows=80000000 width=860)
-                                    predicate:(c_current_addr_sk is not null and c_customer_sk is not null)
-                                    TableScan [TS_0] (rows=80000000 width=860)
-                                      default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_addr_sk"]
-                            <-Map 6 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_52]
-                                PartitionCols:_col0
-                                Select Operator [SEL_51] (rows=40000000 width=1014)
-                                  Output:["_col0","_col1","_col2"]
-                                  Filter Operator [FIL_50] (rows=40000000 width=1014)
-                                    predicate:ca_address_sk is not null
-                                    TableScan [TS_3] (rows=40000000 width=1014)
-                                      default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state","ca_zip"]
-                        <-Reducer 8 [SIMPLE_EDGE]
-                          SHUFFLE [RS_20]
-                            PartitionCols:_col1
-                            Merge Join Operator [MERGEJOIN_45] (rows=316788826 width=135)
-                              Conds:RS_55._col0=RS_58._col0(Inner),Output:["_col1","_col2"]
-                            <-Map 7 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_55]
-                                PartitionCols:_col0
-                                Select Operator [SEL_54] (rows=287989836 width=135)
-                                  Output:["_col0","_col1","_col2"]
-                                  Filter Operator [FIL_53] (rows=287989836 width=135)
-                                    predicate:(cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
-                                    TableScan [TS_6] (rows=287989836 width=135)
-                                      default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_sales_price"]
-                            <-Map 9 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_58]
-                                PartitionCols:_col0
-                                Select Operator [SEL_57] (rows=18262 width=1119)
-                                  Output:["_col0"]
-                                  Filter Operator [FIL_56] (rows=18262 width=1119)
-                                    predicate:((d_qoy = 2) and (d_year = 2000) and d_date_sk is not null)
-                                    TableScan [TS_9] (rows=73049 width=1119)
-                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
+                    Top N Key Operator [TNK_44] (rows=348467716 width=135)
+                      keys:_col4,sort order:+,top n:100
+                      Select Operator [SEL_23] (rows=348467716 width=135)
+                        Output:["_col4","_col7"]
+                        Filter Operator [FIL_22] (rows=348467716 width=135)
+                          predicate:((_col3) IN ('CA', 'WA', 'GA') or (_col7 > 500) or (substr(_col4, 1, 5)) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792'))
+                          Merge Join Operator [MERGEJOIN_47] (rows=348467716 width=135)
+                            Conds:RS_19._col0=RS_20._col1(Inner),Output:["_col3","_col4","_col7"]
+                          <-Reducer 2 [SIMPLE_EDGE]
+                            SHUFFLE [RS_19]
+                              PartitionCols:_col0
+                              Merge Join Operator [MERGEJOIN_45] (rows=88000001 width=860)
+                                Conds:RS_50._col1=RS_53._col0(Inner),Output:["_col0","_col3","_col4"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_50]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_49] (rows=80000000 width=860)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_48] (rows=80000000 width=860)
+                                      predicate:(c_current_addr_sk is not null and c_customer_sk is not null)
+                                      TableScan [TS_0] (rows=80000000 width=860)
+                                        default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_addr_sk"]
+                              <-Map 6 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_53]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_52] (rows=40000000 width=1014)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_51] (rows=40000000 width=1014)
+                                      predicate:ca_address_sk is not null
+                                      TableScan [TS_3] (rows=40000000 width=1014)
+                                        default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state","ca_zip"]
+                          <-Reducer 8 [SIMPLE_EDGE]
+                            SHUFFLE [RS_20]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_46] (rows=316788826 width=135)
+                                Conds:RS_56._col0=RS_59._col0(Inner),Output:["_col1","_col2"]
+                              <-Map 7 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_56]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_55] (rows=287989836 width=135)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_54] (rows=287989836 width=135)
+                                      predicate:(cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                      TableScan [TS_6] (rows=287989836 width=135)
+                                        default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_sales_price"]
+                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_59]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_58] (rows=18262 width=1119)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_57] (rows=18262 width=1119)
+                                      predicate:((d_qoy = 2) and (d_year = 2000) and d_date_sk is not null)
+                                      TableScan [TS_9] (rows=73049 width=1119)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query17.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query17.q.out b/ql/src/test/results/clientpositive/perf/tez/query17.q.out
index 0551653..7757fbd 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query17.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query17.q.out
@@ -104,124 +104,126 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_129]
-        Limit [LIM_128] (rows=100 width=88)
+      File Output Operator [FS_130]
+        Limit [LIM_129] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_127] (rows=421657640 width=88)
+          Select Operator [SEL_128] (rows=421657640 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_126]
-              Select Operator [SEL_125] (rows=421657640 width=88)
+            SHUFFLE [RS_127]
+              Select Operator [SEL_126] (rows=421657640 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
-                Group By Operator [GBY_124] (rows=421657640 width=88)
+                Group By Operator [GBY_125] (rows=421657640 width=88)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","count(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","count(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)"],keys:KEY._col0, KEY._col1, KEY._col2
                 <-Reducer 5 [SIMPLE_EDGE]
                   SHUFFLE [RS_50]
                     PartitionCols:_col0, _col1, _col2
                     Group By Operator [GBY_49] (rows=843315281 width=88)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["count(_col3)","sum(_col3)","sum(_col7)","sum(_col6)","count(_col4)","sum(_col4)","sum(_col9)","sum(_col8)","count(_col5)","sum(_col5)","sum(_col11)","sum(_col10)"],keys:_col0, _col1, _col2
-                      Select Operator [SEL_47] (rows=843315281 width=88)
-                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
-                        Merge Join Operator [MERGEJOIN_99] (rows=843315281 width=88)
-                          Conds:RS_44._col3=RS_123._col0(Inner),Output:["_col5","_col9","_col10","_col14","_col21","_col25"]
-                        <-Map 15 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_123]
-                            PartitionCols:_col0
-                            Select Operator [SEL_122] (rows=1704 width=1910)
-                              Output:["_col0","_col1"]
-                              Filter Operator [FIL_121] (rows=1704 width=1910)
-                                predicate:s_store_sk is not null
-                                TableScan [TS_32] (rows=1704 width=1910)
-                                  default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
-                        <-Reducer 4 [SIMPLE_EDGE]
-                          SHUFFLE [RS_44]
-                            PartitionCols:_col3
-                            Merge Join Operator [MERGEJOIN_98] (rows=766650239 width=88)
-                              Conds:RS_41._col1, _col2, _col4=RS_42._col7, _col8, _col9(Inner),Output:["_col3","_col5","_col9","_col10","_col14","_col21"]
-                            <-Reducer 10 [SIMPLE_EDGE]
-                              SHUFFLE [RS_42]
-                                PartitionCols:_col7, _col8, _col9
-                                Merge Join Operator [MERGEJOIN_97] (rows=348467716 width=135)
-                                  Conds:RS_28._col2, _col1=RS_29._col1, _col2(Inner),Output:["_col3","_col7","_col8","_col9","_col10"]
-                                <-Reducer 11 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_29]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_96] (rows=63350266 width=77)
-                                      Conds:RS_120._col0=RS_111._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                    <-Map 8 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_111]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_108] (rows=36525 width=1119)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_105] (rows=36525 width=1119)
-                                            predicate:((d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3') and d_date_sk is not null)
-                                            TableScan [TS_3] (rows=73049 width=1119)
-                                              default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_quarter_name"]
-                                    <-Map 14 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_120]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_119] (rows=57591150 width=77)
-                                          Output:["_col0","_col1","_col2","_col3","_col4"]
-                                          Filter Operator [FIL_118] (rows=57591150 width=77)
-                                            predicate:(sr_customer_sk is not null and sr_item_sk is not null and sr_returned_date_sk is not null and sr_ticket_number is not null)
-                                            TableScan [TS_15] (rows=57591150 width=77)
-                                              default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_return_quantity"]
-                                <-Reducer 9 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_28]
-                                    PartitionCols:_col2, _col1
-                                    Merge Join Operator [MERGEJOIN_95] (rows=316788826 width=135)
-                                      Conds:RS_117._col0=RS_110._col0(Inner),Output:["_col1","_col2","_col3"]
-                                    <-Map 8 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_110]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_107] (rows=36525 width=1119)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_104] (rows=36525 width=1119)
-                                            predicate:((d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3') and d_date_sk is not null)
-                                             Please refer to the previous TableScan [TS_3]
-                                    <-Map 13 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_117]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_116] (rows=287989836 width=135)
-                                          Output:["_col0","_col1","_col2","_col3"]
-                                          Filter Operator [FIL_115] (rows=287989836 width=135)
-                                            predicate:(cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
-                                            TableScan [TS_9] (rows=287989836 width=135)
-                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity"]
-                            <-Reducer 3 [SIMPLE_EDGE]
-                              SHUFFLE [RS_41]
-                                PartitionCols:_col1, _col2, _col4
-                                Merge Join Operator [MERGEJOIN_94] (rows=696954748 width=88)
-                                  Conds:RS_38._col1=RS_114._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col9","_col10"]
-                                <-Map 12 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_114]
-                                    PartitionCols:_col0
-                                    Select Operator [SEL_113] (rows=462000 width=1436)
-                                      Output:["_col0","_col1","_col2"]
-                                      Filter Operator [FIL_112] (rows=462000 width=1436)
-                                        predicate:i_item_sk is not null
-                                        TableScan [TS_6] (rows=462000 width=1436)
-                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
-                                <-Reducer 2 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_38]
-                                    PartitionCols:_col1
-                                    Merge Join Operator [MERGEJOIN_93] (rows=633595212 width=88)
-                                      Conds:RS_102._col0=RS_109._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
-                                    <-Map 8 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_109]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_106] (rows=36524 width=1119)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_103] (rows=36524 width=1119)
-                                            predicate:((d_quarter_name = '2000Q1') and d_date_sk is not null)
-                                             Please refer to the previous TableScan [TS_3]
-                                    <-Map 1 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_102]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_101] (rows=575995635 width=88)
-                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                          Filter Operator [FIL_100] (rows=575995635 width=88)
-                                            predicate:(ss_customer_sk is not null and ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_ticket_number 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_customer_sk","ss_store_sk","ss_ticket_number","ss_quantity"]
+                      Top N Key Operator [TNK_93] (rows=843315281 width=88)
+                        keys:_col0, _col1, _col2,sort order:+++,top n:100
+                        Select Operator [SEL_47] (rows=843315281 width=88)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                          Merge Join Operator [MERGEJOIN_100] (rows=843315281 width=88)
+                            Conds:RS_44._col3=RS_124._col0(Inner),Output:["_col5","_col9","_col10","_col14","_col21","_col25"]
+                          <-Map 15 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_124]
+                              PartitionCols:_col0
+                              Select Operator [SEL_123] (rows=1704 width=1910)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_122] (rows=1704 width=1910)
+                                  predicate:s_store_sk is not null
+                                  TableScan [TS_32] (rows=1704 width=1910)
+                                    default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_44]
+                              PartitionCols:_col3
+                              Merge Join Operator [MERGEJOIN_99] (rows=766650239 width=88)
+                                Conds:RS_41._col1, _col2, _col4=RS_42._col7, _col8, _col9(Inner),Output:["_col3","_col5","_col9","_col10","_col14","_col21"]
+                              <-Reducer 10 [SIMPLE_EDGE]
+                                SHUFFLE [RS_42]
+                                  PartitionCols:_col7, _col8, _col9
+                                  Merge Join Operator [MERGEJOIN_98] (rows=348467716 width=135)
+                                    Conds:RS_28._col2, _col1=RS_29._col1, _col2(Inner),Output:["_col3","_col7","_col8","_col9","_col10"]
+                                  <-Reducer 11 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_29]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_97] (rows=63350266 width=77)
+                                        Conds:RS_121._col0=RS_112._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_112]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_109] (rows=36525 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_106] (rows=36525 width=1119)
+                                              predicate:((d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3') and d_date_sk is not null)
+                                              TableScan [TS_3] (rows=73049 width=1119)
+                                                default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_quarter_name"]
+                                      <-Map 14 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_121]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_120] (rows=57591150 width=77)
+                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                            Filter Operator [FIL_119] (rows=57591150 width=77)
+                                              predicate:(sr_customer_sk is not null and sr_item_sk is not null and sr_returned_date_sk is not null and sr_ticket_number is not null)
+                                              TableScan [TS_15] (rows=57591150 width=77)
+                                                default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_return_quantity"]
+                                  <-Reducer 9 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_28]
+                                      PartitionCols:_col2, _col1
+                                      Merge Join Operator [MERGEJOIN_96] (rows=316788826 width=135)
+                                        Conds:RS_118._col0=RS_111._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_111]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_108] (rows=36525 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_105] (rows=36525 width=1119)
+                                              predicate:((d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3') and d_date_sk is not null)
+                                               Please refer to the previous TableScan [TS_3]
+                                      <-Map 13 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_118]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_117] (rows=287989836 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_116] (rows=287989836 width=135)
+                                              predicate:(cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_9] (rows=287989836 width=135)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity"]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_41]
+                                  PartitionCols:_col1, _col2, _col4
+                                  Merge Join Operator [MERGEJOIN_95] (rows=696954748 width=88)
+                                    Conds:RS_38._col1=RS_115._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col9","_col10"]
+                                  <-Map 12 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_115]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_114] (rows=462000 width=1436)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_113] (rows=462000 width=1436)
+                                          predicate:i_item_sk is not null
+                                          TableScan [TS_6] (rows=462000 width=1436)
+                                            default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_38]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_94] (rows=633595212 width=88)
+                                        Conds:RS_103._col0=RS_110._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_110]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_107] (rows=36524 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_104] (rows=36524 width=1119)
+                                              predicate:((d_quarter_name = '2000Q1') and d_date_sk is not null)
+                                               Please refer to the previous TableScan [TS_3]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_103]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_102] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                            Filter Operator [FIL_101] (rows=575995635 width=88)
+                                              predicate:(ss_customer_sk is not null and ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_ticket_number 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_customer_sk","ss_store_sk","ss_ticket_number","ss_quantity"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query25.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query25.q.out b/ql/src/test/results/clientpositive/perf/tez/query25.q.out
index 9af27f8..7966437 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query25.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query25.q.out
@@ -110,120 +110,122 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_130]
-        Limit [LIM_129] (rows=100 width=88)
+      File Output Operator [FS_131]
+        Limit [LIM_130] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_128] (rows=421657640 width=88)
+          Select Operator [SEL_129] (rows=421657640 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_127]
-              Group By Operator [GBY_126] (rows=421657640 width=88)
+            SHUFFLE [RS_128]
+              Group By Operator [GBY_127] (rows=421657640 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
               <-Reducer 5 [SIMPLE_EDGE]
                 SHUFFLE [RS_49]
                   PartitionCols:_col0, _col1, _col2, _col3
                   Group By Operator [GBY_48] (rows=843315281 width=88)
                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col5)","sum(_col20)","sum(_col12)"],keys:_col25, _col26, _col28, _col29
-                    Merge Join Operator [MERGEJOIN_101] (rows=843315281 width=88)
-                      Conds:RS_44._col3=RS_125._col0(Inner),Output:["_col5","_col12","_col20","_col25","_col26","_col28","_col29"]
-                    <-Map 15 [SIMPLE_EDGE] vectorized
-                      SHUFFLE [RS_125]
-                        PartitionCols:_col0
-                        Select Operator [SEL_124] (rows=1704 width=1910)
-                          Output:["_col0","_col1","_col2"]
-                          Filter Operator [FIL_123] (rows=1704 width=1910)
-                            predicate:s_store_sk is not null
-                            TableScan [TS_32] (rows=1704 width=1910)
-                              default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name"]
-                    <-Reducer 4 [SIMPLE_EDGE]
-                      SHUFFLE [RS_44]
-                        PartitionCols:_col3
-                        Merge Join Operator [MERGEJOIN_100] (rows=766650239 width=88)
-                          Conds:RS_41._col1=RS_122._col0(Inner),Output:["_col3","_col5","_col12","_col20","_col25","_col26"]
-                        <-Map 14 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_122]
-                            PartitionCols:_col0
-                            Select Operator [SEL_121] (rows=462000 width=1436)
-                              Output:["_col0","_col1","_col2"]
-                              Filter Operator [FIL_120] (rows=462000 width=1436)
-                                predicate:i_item_sk is not null
-                                TableScan [TS_29] (rows=462000 width=1436)
-                                  default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
-                        <-Reducer 3 [SIMPLE_EDGE]
-                          SHUFFLE [RS_41]
-                            PartitionCols:_col1
-                            Merge Join Operator [MERGEJOIN_99] (rows=696954748 width=88)
-                              Conds:RS_38._col1, _col2, _col4=RS_39._col8, _col9, _col10(Inner),Output:["_col1","_col3","_col5","_col12","_col20"]
-                            <-Reducer 10 [SIMPLE_EDGE]
-                              SHUFFLE [RS_39]
-                                PartitionCols:_col8, _col9, _col10
-                                Merge Join Operator [MERGEJOIN_98] (rows=348467716 width=135)
-                                  Conds:RS_25._col2, _col1=RS_26._col1, _col2(Inner),Output:["_col3","_col8","_col9","_col10","_col11"]
-                                <-Reducer 11 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_26]
-                                    PartitionCols:_col1, _col2
-                                    Merge Join Operator [MERGEJOIN_97] (rows=63350266 width=77)
-                                      Conds:RS_119._col0=RS_113._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                    <-Map 8 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_113]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_110] (rows=4058 width=1119)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_107] (rows=4058 width=1119)
-                                            predicate:((d_year = 2000) and d_date_sk is not null and d_moy BETWEEN 4 AND 10)
-                                            TableScan [TS_3] (rows=73049 width=1119)
-                                              default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
-                                    <-Map 13 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_119]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_118] (rows=57591150 width=77)
-                                          Output:["_col0","_col1","_col2","_col3","_col4"]
-                                          Filter Operator [FIL_117] (rows=57591150 width=77)
-                                            predicate:(sr_customer_sk is not null and sr_item_sk is not null and sr_returned_date_sk is not null and sr_ticket_number is not null)
-                                            TableScan [TS_12] (rows=57591150 width=77)
-                                              default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_net_loss"]
-                                <-Reducer 9 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_25]
-                                    PartitionCols:_col2, _col1
-                                    Merge Join Operator [MERGEJOIN_96] (rows=316788826 width=135)
-                                      Conds:RS_116._col0=RS_112._col0(Inner),Output:["_col1","_col2","_col3"]
-                                    <-Map 8 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_112]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_109] (rows=4058 width=1119)
-                                          Output:["_col0"]
-                                          Filter Operator [FIL_106] (rows=4058 width=1119)
-                                            predicate:((d_year = 2000) and d_date_sk is not null and d_moy BETWEEN 4 AND 10)
-                                             Please refer to the previous TableScan [TS_3]
-                                    <-Map 12 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_116]
-                                        PartitionCols:_col0
-                                        Select Operator [SEL_115] (rows=287989836 width=135)
-                                          Output:["_col0","_col1","_col2","_col3"]
-                                          Filter Operator [FIL_114] (rows=287989836 width=135)
-                                            predicate:(cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
-                                            TableScan [TS_6] (rows=287989836 width=135)
-                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_net_profit"]
-                            <-Reducer 2 [SIMPLE_EDGE]
-                              SHUFFLE [RS_38]
-                                PartitionCols:_col1, _col2, _col4
-                                Merge Join Operator [MERGEJOIN_95] (rows=633595212 width=88)
-                                  Conds:RS_104._col0=RS_111._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
-                                <-Map 8 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_111]
-                                    PartitionCols:_col0
-                                    Select Operator [SEL_108] (rows=18262 width=1119)
-                                      Output:["_col0"]
-                                      Filter Operator [FIL_105] (rows=18262 width=1119)
-                                        predicate:((d_moy = 4) and (d_year = 2000) and d_date_sk is not null)
-                                         Please refer to the previous TableScan [TS_3]
-                                <-Map 1 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_104]
-                                    PartitionCols:_col0
-                                    Select Operator [SEL_103] (rows=575995635 width=88)
-                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                      Filter Operator [FIL_102] (rows=575995635 width=88)
-                                        predicate:(ss_customer_sk is not null and ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_ticket_number 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_customer_sk","ss_store_sk","ss_ticket_number","ss_net_profit"]
+                    Top N Key Operator [TNK_95] (rows=843315281 width=88)
+                      keys:_col25, _col26, _col28, _col29,sort order:++++,top n:100
+                      Merge Join Operator [MERGEJOIN_102] (rows=843315281 width=88)
+                        Conds:RS_44._col3=RS_126._col0(Inner),Output:["_col5","_col12","_col20","_col25","_col26","_col28","_col29"]
+                      <-Map 15 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_126]
+                          PartitionCols:_col0
+                          Select Operator [SEL_125] (rows=1704 width=1910)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_124] (rows=1704 width=1910)
+                              predicate:s_store_sk is not null
+                              TableScan [TS_32] (rows=1704 width=1910)
+                                default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name"]
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_44]
+                          PartitionCols:_col3
+                          Merge Join Operator [MERGEJOIN_101] (rows=766650239 width=88)
+                            Conds:RS_41._col1=RS_123._col0(Inner),Output:["_col3","_col5","_col12","_col20","_col25","_col26"]
+                          <-Map 14 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_123]
+                              PartitionCols:_col0
+                              Select Operator [SEL_122] (rows=462000 width=1436)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_121] (rows=462000 width=1436)
+                                  predicate:i_item_sk is not null
+                                  TableScan [TS_29] (rows=462000 width=1436)
+                                    default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                          <-Reducer 3 [SIMPLE_EDGE]
+                            SHUFFLE [RS_41]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_100] (rows=696954748 width=88)
+                                Conds:RS_38._col1, _col2, _col4=RS_39._col8, _col9, _col10(Inner),Output:["_col1","_col3","_col5","_col12","_col20"]
+                              <-Reducer 10 [SIMPLE_EDGE]
+                                SHUFFLE [RS_39]
+                                  PartitionCols:_col8, _col9, _col10
+                                  Merge Join Operator [MERGEJOIN_99] (rows=348467716 width=135)
+                                    Conds:RS_25._col2, _col1=RS_26._col1, _col2(Inner),Output:["_col3","_col8","_col9","_col10","_col11"]
+                                  <-Reducer 11 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_26]
+                                      PartitionCols:_col1, _col2
+                                      Merge Join Operator [MERGEJOIN_98] (rows=63350266 width=77)
+                                        Conds:RS_120._col0=RS_114._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_114]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_111] (rows=4058 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_108] (rows=4058 width=1119)
+                                              predicate:((d_year = 2000) and d_date_sk is not null and d_moy BETWEEN 4 AND 10)
+                                              TableScan [TS_3] (rows=73049 width=1119)
+                                                default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 13 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_120]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_119] (rows=57591150 width=77)
+                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                            Filter Operator [FIL_118] (rows=57591150 width=77)
+                                              predicate:(sr_customer_sk is not null and sr_item_sk is not null and sr_returned_date_sk is not null and sr_ticket_number is not null)
+                                              TableScan [TS_12] (rows=57591150 width=77)
+                                                default@store_returns,store_returns,Tbl:COMPLETE,Col:NONE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_net_loss"]
+                                  <-Reducer 9 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_25]
+                                      PartitionCols:_col2, _col1
+                                      Merge Join Operator [MERGEJOIN_97] (rows=316788826 width=135)
+                                        Conds:RS_117._col0=RS_113._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_113]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_110] (rows=4058 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_107] (rows=4058 width=1119)
+                                              predicate:((d_year = 2000) and d_date_sk is not null and d_moy BETWEEN 4 AND 10)
+                                               Please refer to the previous TableScan [TS_3]
+                                      <-Map 12 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_117]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_116] (rows=287989836 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_115] (rows=287989836 width=135)
+                                              predicate:(cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_6] (rows=287989836 width=135)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_net_profit"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_38]
+                                  PartitionCols:_col1, _col2, _col4
+                                  Merge Join Operator [MERGEJOIN_96] (rows=633595212 width=88)
+                                    Conds:RS_105._col0=RS_112._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                  <-Map 8 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_112]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_109] (rows=18262 width=1119)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_106] (rows=18262 width=1119)
+                                          predicate:((d_moy = 4) and (d_year = 2000) and d_date_sk is not null)
+                                           Please refer to the previous TableScan [TS_3]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_105]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_104] (rows=575995635 width=88)
+                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                        Filter Operator [FIL_103] (rows=575995635 width=88)
+                                          predicate:(ss_customer_sk is not null and ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null and ss_ticket_number 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_customer_sk","ss_store_sk","ss_ticket_number","ss_net_profit"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query26.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query26.q.out b/ql/src/test/results/clientpositive/perf/tez/query26.q.out
index f113113..8bf79e1 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query26.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query26.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=135)
+      File Output Operator [FS_80]
+        Limit [LIM_79] (rows=100 width=135)
           Number of rows:100
-          Select Operator [SEL_77] (rows=210822976 width=135)
+          Select Operator [SEL_78] (rows=210822976 width=135)
             Output:["_col0","_col1","_col2","_col3","_col4"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_76]
-              Select Operator [SEL_75] (rows=210822976 width=135)
+            SHUFFLE [RS_77]
+              Select Operator [SEL_76] (rows=210822976 width=135)
                 Output:["_col0","_col1","_col2","_col3","_col4"]
-                Group By Operator [GBY_74] (rows=210822976 width=135)
+                Group By Operator [GBY_75] (rows=210822976 width=135)
                   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=421645953 width=135)
                       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=421645953 width=135)
-                        Conds:RS_24._col2=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:_col2
-                          Merge Join Operator [MERGEJOIN_57] (rows=383314495 width=135)
-                            Conds:RS_21._col3=RS_70._col0(Inner),Output:["_col2","_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=348467716 width=135)
-                                Conds:RS_18._col0=RS_67._col0(Inner),Output:["_col2","_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=316788826 width=135)
-                                    Conds:RS_61._col1=RS_64._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                  <-Map 1 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_61]
-                                      PartitionCols:_col1
-                                      Select Operator [SEL_60] (rows=287989836 width=135)
-                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                                        Filter Operator [FIL_59] (rows=287989836 width=135)
-                                          predicate:(cs_bill_cdemo_sk is not null and cs_item_sk is not null and cs_promo_sk is not null and cs_sold_date_sk is not null)
-                                          TableScan [TS_0] (rows=287989836 width=135)
-                                            default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_cdemo_sk","cs_item_sk","cs_promo_sk","cs_quantity","cs_list_price","cs_sales_price","cs_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=421645953 width=135)
+                        keys:_col18,sort order:+,top n:100
+                        Merge Join Operator [MERGEJOIN_59] (rows=421645953 width=135)
+                          Conds:RS_24._col2=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:_col2
+                            Merge Join Operator [MERGEJOIN_58] (rows=383314495 width=135)
+                              Conds:RS_21._col3=RS_71._col0(Inner),Output:["_col2","_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=348467716 width=135)
+                                  Conds:RS_18._col0=RS_68._col0(Inner),Output:["_col2","_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=316788826 width=135)
+                                      Conds:RS_62._col1=RS_65._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_62]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_61] (rows=287989836 width=135)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_60] (rows=287989836 width=135)
+                                            predicate:(cs_bill_cdemo_sk is not null and cs_item_sk is not null and cs_promo_sk is not null and cs_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=287989836 width=135)
+                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_cdemo_sk","cs_item_sk","cs_promo_sk","cs_quantity","cs_list_price","cs_sales_price","cs_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"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query27.q.out
----------------------------------------------------------------------
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 0839118..cfa5cca 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query27.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query27.q.out
@@ -57,84 +57,86 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_80]
-        Limit [LIM_79] (rows=100 width=88)
+      File Output Operator [FS_81]
+        Limit [LIM_80] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_78] (rows=1264972921 width=88)
+          Select Operator [SEL_79] (rows=1264972921 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_77]
-              Select Operator [SEL_76] (rows=1264972921 width=88)
+            SHUFFLE [RS_78]
+              Select Operator [SEL_77] (rows=1264972921 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
-                Group By Operator [GBY_75] (rows=1264972921 width=88)
+                Group By Operator [GBY_76] (rows=1264972921 width=88)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],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, KEY._col1, KEY._col2
                 <-Reducer 5 [SIMPLE_EDGE]
                   SHUFFLE [RS_30]
                     PartitionCols:_col0, _col1, _col2
                     Group By Operator [GBY_29] (rows=2529945843 width=88)
                       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
-                      Select Operator [SEL_27] (rows=843315281 width=88)
-                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                        Merge Join Operator [MERGEJOIN_59] (rows=843315281 width=88)
-                          Conds:RS_24._col1=RS_74._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col15","_col17"]
-                        <-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","_col15"]
-                            <-Map 10 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_71]
-                                PartitionCols:_col0
-                                Select Operator [SEL_70] (rows=852 width=1910)
-                                  Output:["_col0","_col1"]
-                                  Filter Operator [FIL_69] (rows=852 width=1910)
-                                    predicate:((s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC') and s_store_sk is not null)
-                                    TableScan [TS_9] (rows=1704 width=1910)
-                                      default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
-                            <-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 = 2001) 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_sold_date_sk is not null and ss_store_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_store_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 = '2 yr Degree') and (cd_gender = 'M') and (cd_marital_status = 'U') 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_56] (rows=843315281 width=88)
+                        keys:_col0, _col1, 0L,sort order:+++,top n:100
+                        Select Operator [SEL_27] (rows=843315281 width=88)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Merge Join Operator [MERGEJOIN_60] (rows=843315281 width=88)
+                            Conds:RS_24._col1=RS_75._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col15","_col17"]
+                          <-Map 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_75]
+                              PartitionCols:_col0
+                              Select Operator [SEL_74] (rows=462000 width=1436)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_73] (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_59] (rows=766650239 width=88)
+                                Conds:RS_21._col3=RS_72._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col15"]
+                              <-Map 10 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_72]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_71] (rows=852 width=1910)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_70] (rows=852 width=1910)
+                                      predicate:((s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC') and s_store_sk is not null)
+                                      TableScan [TS_9] (rows=1704 width=1910)
+                                        default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_state"]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_21]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_58] (rows=696954748 width=88)
+                                    Conds:RS_18._col0=RS_69._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                  <-Map 9 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_69]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_68] (rows=36524 width=1119)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_67] (rows=36524 width=1119)
+                                          predicate:((d_year = 2001) 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_57] (rows=633595212 width=88)
+                                        Conds:RS_63._col2=RS_66._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_63]
+                                          PartitionCols:_col2
+                                          Select Operator [SEL_62] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                            Filter Operator [FIL_61] (rows=575995635 width=88)
+                                              predicate:(ss_cdemo_sk is not null and ss_item_sk is not null and ss_sold_date_sk is not null and ss_store_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_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_66]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_65] (rows=232725 width=385)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_64] (rows=232725 width=385)
+                                              predicate:((cd_education_status = '2 yr Degree') and (cd_gender = 'M') and (cd_marital_status = 'U') 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"]