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

[07/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/query29.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query29.q.out b/ql/src/test/results/clientpositive/perf/tez/query29.q.out
index a0e7621..b15ae42 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query29.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query29.q.out
@@ -108,123 +108,125 @@ Stage-0
     limit:100
     Stage-1
       Reducer 5 vectorized
-      File Output Operator [FS_128]
-        Limit [LIM_127] (rows=100 width=88)
+      File Output Operator [FS_129]
+        Limit [LIM_128] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_126] (rows=463823414 width=88)
+          Select Operator [SEL_127] (rows=463823414 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
           <-Reducer 4 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_125]
-              Group By Operator [GBY_124] (rows=463823414 width=88)
+            SHUFFLE [RS_126]
+              Group By Operator [GBY_125] (rows=463823414 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 3 [SIMPLE_EDGE]
                 SHUFFLE [RS_49]
                   PartitionCols:_col0, _col1, _col2, _col3
                   Group By Operator [GBY_48] (rows=927646829 width=88)
                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col14)","sum(_col22)","sum(_col3)"],keys:_col7, _col8, _col27, _col28
-                    Merge Join Operator [MERGEJOIN_99] (rows=927646829 width=88)
-                      Conds:RS_44._col1, _col2=RS_45._col14, _col13(Inner),Output:["_col3","_col7","_col8","_col14","_col22","_col27","_col28"]
-                    <-Reducer 11 [SIMPLE_EDGE]
-                      SHUFFLE [RS_45]
-                        PartitionCols:_col14, _col13
-                        Select Operator [SEL_40] (rows=843315281 width=88)
-                          Output:["_col1","_col2","_col8","_col13","_col14","_col16","_col21","_col22"]
-                          Merge Join Operator [MERGEJOIN_98] (rows=843315281 width=88)
-                            Conds:RS_37._col3=RS_123._col0(Inner),Output:["_col5","_col10","_col11","_col13","_col18","_col19","_col21","_col22"]
-                          <-Map 16 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_123]
+                    Top N Key Operator [TNK_93] (rows=927646829 width=88)
+                      keys:_col7, _col8, _col27, _col28,sort order:++++,top n:100
+                      Merge Join Operator [MERGEJOIN_100] (rows=927646829 width=88)
+                        Conds:RS_44._col1, _col2=RS_45._col14, _col13(Inner),Output:["_col3","_col7","_col8","_col14","_col22","_col27","_col28"]
+                      <-Reducer 11 [SIMPLE_EDGE]
+                        SHUFFLE [RS_45]
+                          PartitionCols:_col14, _col13
+                          Select Operator [SEL_40] (rows=843315281 width=88)
+                            Output:["_col1","_col2","_col8","_col13","_col14","_col16","_col21","_col22"]
+                            Merge Join Operator [MERGEJOIN_99] (rows=843315281 width=88)
+                              Conds:RS_37._col3=RS_124._col0(Inner),Output:["_col5","_col10","_col11","_col13","_col18","_col19","_col21","_col22"]
+                            <-Map 16 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_124]
+                                PartitionCols:_col0
+                                Select Operator [SEL_123] (rows=1704 width=1910)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_122] (rows=1704 width=1910)
+                                    predicate:s_store_sk is not null
+                                    TableScan [TS_25] (rows=1704 width=1910)
+                                      default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name"]
+                            <-Reducer 10 [SIMPLE_EDGE]
+                              SHUFFLE [RS_37]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_98] (rows=766650239 width=88)
+                                  Conds:RS_34._col1=RS_121._col0(Inner),Output:["_col3","_col5","_col10","_col11","_col13","_col18","_col19"]
+                                <-Map 15 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_121]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_120] (rows=462000 width=1436)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_119] (rows=462000 width=1436)
+                                        predicate:i_item_sk is not null
+                                        TableScan [TS_22] (rows=462000 width=1436)
+                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_34]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_97] (rows=696954748 width=88)
+                                      Conds:RS_31._col1, _col2, _col4=RS_32._col1, _col2, _col3(Inner),Output:["_col1","_col3","_col5","_col10","_col11","_col13"]
+                                    <-Reducer 13 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_32]
+                                        PartitionCols:_col1, _col2, _col3
+                                        Merge Join Operator [MERGEJOIN_96] (rows=63350266 width=77)
+                                          Conds:RS_118._col0=RS_115._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                        <-Map 12 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_115]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_113] (rows=4058 width=1119)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_111] (rows=4058 width=1119)
+                                                predicate:((d_year = 1999) and d_date_sk is not null and d_moy BETWEEN 4 AND 7)
+                                                TableScan [TS_9] (rows=73049 width=1119)
+                                                  default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                        <-Map 14 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_118]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_117] (rows=57591150 width=77)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                              Filter Operator [FIL_116] (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_return_quantity"]
+                                    <-Reducer 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_31]
+                                        PartitionCols:_col1, _col2, _col4
+                                        Merge Join Operator [MERGEJOIN_95] (rows=633595212 width=88)
+                                          Conds:RS_109._col0=RS_114._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                        <-Map 12 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_114]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_112] (rows=18262 width=1119)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_110] (rows=18262 width=1119)
+                                                predicate:((d_moy = 4) and (d_year = 1999) and d_date_sk is not null)
+                                                 Please refer to the previous TableScan [TS_9]
+                                        <-Map 7 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_109]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_108] (rows=575995635 width=88)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_107] (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_6] (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"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_44]
+                          PartitionCols:_col1, _col2
+                          Merge Join Operator [MERGEJOIN_94] (rows=316788826 width=135)
+                            Conds:RS_103._col0=RS_106._col0(Inner),Output:["_col1","_col2","_col3"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_103]
                               PartitionCols:_col0
-                              Select Operator [SEL_122] (rows=1704 width=1910)
-                                Output:["_col0","_col1","_col2"]
-                                Filter Operator [FIL_121] (rows=1704 width=1910)
-                                  predicate:s_store_sk is not null
-                                  TableScan [TS_25] (rows=1704 width=1910)
-                                    default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name"]
-                          <-Reducer 10 [SIMPLE_EDGE]
-                            SHUFFLE [RS_37]
-                              PartitionCols:_col3
-                              Merge Join Operator [MERGEJOIN_97] (rows=766650239 width=88)
-                                Conds:RS_34._col1=RS_120._col0(Inner),Output:["_col3","_col5","_col10","_col11","_col13","_col18","_col19"]
-                              <-Map 15 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_120]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_119] (rows=462000 width=1436)
-                                    Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_118] (rows=462000 width=1436)
-                                      predicate:i_item_sk is not null
-                                      TableScan [TS_22] (rows=462000 width=1436)
-                                        default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc"]
-                              <-Reducer 9 [SIMPLE_EDGE]
-                                SHUFFLE [RS_34]
-                                  PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_96] (rows=696954748 width=88)
-                                    Conds:RS_31._col1, _col2, _col4=RS_32._col1, _col2, _col3(Inner),Output:["_col1","_col3","_col5","_col10","_col11","_col13"]
-                                  <-Reducer 13 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_32]
-                                      PartitionCols:_col1, _col2, _col3
-                                      Merge Join Operator [MERGEJOIN_95] (rows=63350266 width=77)
-                                        Conds:RS_117._col0=RS_114._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
-                                      <-Map 12 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_114]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_112] (rows=4058 width=1119)
-                                            Output:["_col0"]
-                                            Filter Operator [FIL_110] (rows=4058 width=1119)
-                                              predicate:((d_year = 1999) and d_date_sk is not null and d_moy BETWEEN 4 AND 7)
-                                              TableScan [TS_9] (rows=73049 width=1119)
-                                                default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
-                                      <-Map 14 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_117]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_116] (rows=57591150 width=77)
-                                            Output:["_col0","_col1","_col2","_col3","_col4"]
-                                            Filter Operator [FIL_115] (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_return_quantity"]
-                                  <-Reducer 8 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_31]
-                                      PartitionCols:_col1, _col2, _col4
-                                      Merge Join Operator [MERGEJOIN_94] (rows=633595212 width=88)
-                                        Conds:RS_108._col0=RS_113._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
-                                      <-Map 12 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_113]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_111] (rows=18262 width=1119)
-                                            Output:["_col0"]
-                                            Filter Operator [FIL_109] (rows=18262 width=1119)
-                                              predicate:((d_moy = 4) and (d_year = 1999) and d_date_sk is not null)
-                                               Please refer to the previous TableScan [TS_9]
-                                      <-Map 7 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_108]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_107] (rows=575995635 width=88)
-                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                            Filter Operator [FIL_106] (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_6] (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"]
-                    <-Reducer 2 [SIMPLE_EDGE]
-                      SHUFFLE [RS_44]
-                        PartitionCols:_col1, _col2
-                        Merge Join Operator [MERGEJOIN_93] (rows=316788826 width=135)
-                          Conds:RS_102._col0=RS_105._col0(Inner),Output:["_col1","_col2","_col3"]
-                        <-Map 1 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_102]
-                            PartitionCols:_col0
-                            Select Operator [SEL_101] (rows=287989836 width=135)
-                              Output:["_col0","_col1","_col2","_col3"]
-                              Filter Operator [FIL_100] (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_0] (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"]
-                        <-Map 6 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_105]
-                            PartitionCols:_col0
-                            Select Operator [SEL_104] (rows=36525 width=1119)
-                              Output:["_col0"]
-                              Filter Operator [FIL_103] (rows=36525 width=1119)
-                                predicate:((d_year) IN (1999, 2000, 2001) and d_date_sk is not null)
-                                TableScan [TS_3] (rows=73049 width=1119)
-                                  default@date_dim,d3,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                              Select Operator [SEL_102] (rows=287989836 width=135)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Filter Operator [FIL_101] (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_0] (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"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_106]
+                              PartitionCols:_col0
+                              Select Operator [SEL_105] (rows=36525 width=1119)
+                                Output:["_col0"]
+                                Filter Operator [FIL_104] (rows=36525 width=1119)
+                                  predicate:((d_year) IN (1999, 2000, 2001) and d_date_sk is not null)
+                                  TableScan [TS_3] (rows=73049 width=1119)
+                                    default@date_dim,d3,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query35.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query35.q.out b/ql/src/test/results/clientpositive/perf/tez/query35.q.out
index 772f994..bf17313 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query35.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query35.q.out
@@ -129,144 +129,146 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 6 vectorized
-      File Output Operator [FS_144]
-        Limit [LIM_143] (rows=100 width=88)
+      File Output Operator [FS_145]
+        Limit [LIM_144] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_142] (rows=1045432122 width=88)
+          Select Operator [SEL_143] (rows=1045432122 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16"]
           <-Reducer 5 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_141]
-              Select Operator [SEL_140] (rows=1045432122 width=88)
+            SHUFFLE [RS_142]
+              Select Operator [SEL_141] (rows=1045432122 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17"]
-                Group By Operator [GBY_139] (rows=1045432122 width=88)
+                Group By Operator [GBY_140] (rows=1045432122 width=88)
                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","count(VALUE._col2)","max(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","max(VALUE._col6)","sum(VALUE._col7)","count(VALUE._col8)","max(VALUE._col9)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
                 <-Reducer 4 [SIMPLE_EDGE]
                   SHUFFLE [RS_63]
                     PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
                     Group By Operator [GBY_62] (rows=2090864244 width=88)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"],aggregations:["count()","sum(_col8)","count(_col8)","max(_col8)","sum(_col9)","count(_col9)","max(_col9)","sum(_col10)","count(_col10)","max(_col10)"],keys:_col4, _col6, _col7, _col8, _col9, _col10
-                      Select Operator [SEL_61] (rows=2090864244 width=88)
-                        Output:["_col4","_col6","_col7","_col8","_col9","_col10"]
-                        Filter Operator [FIL_60] (rows=2090864244 width=88)
-                          predicate:(_col12 is not null or _col14 is not null)
-                          Merge Join Operator [MERGEJOIN_109] (rows=2090864244 width=88)
-                            Conds:RS_55._col0=RS_56._col0(Left Semi),RS_55._col0=RS_132._col0(Left Outer),RS_55._col0=RS_138._col0(Left Outer),Output:["_col4","_col6","_col7","_col8","_col9","_col10","_col12","_col14"]
-                          <-Reducer 10 [SIMPLE_EDGE]
-                            SHUFFLE [RS_56]
-                              PartitionCols:_col0
-                              Group By Operator [GBY_54] (rows=633595212 width=88)
-                                Output:["_col0"],keys:_col0
-                                Select Operator [SEL_18] (rows=633595212 width=88)
-                                  Output:["_col0"]
-                                  Merge Join Operator [MERGEJOIN_106] (rows=633595212 width=88)
-                                    Conds:RS_121._col0=RS_124._col0(Inner),Output:["_col1"]
-                                  <-Map 11 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_124]
+                      Top N Key Operator [TNK_104] (rows=2090864244 width=88)
+                        keys:_col4, _col6, _col7, _col8, _col9, _col10,sort order:++++++,top n:100
+                        Select Operator [SEL_61] (rows=2090864244 width=88)
+                          Output:["_col4","_col6","_col7","_col8","_col9","_col10"]
+                          Filter Operator [FIL_60] (rows=2090864244 width=88)
+                            predicate:(_col12 is not null or _col14 is not null)
+                            Merge Join Operator [MERGEJOIN_110] (rows=2090864244 width=88)
+                              Conds:RS_55._col0=RS_56._col0(Left Semi),RS_55._col0=RS_133._col0(Left Outer),RS_55._col0=RS_139._col0(Left Outer),Output:["_col4","_col6","_col7","_col8","_col9","_col10","_col12","_col14"]
+                            <-Reducer 10 [SIMPLE_EDGE]
+                              SHUFFLE [RS_56]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_54] (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_122._col0=RS_125._col0(Inner),Output:["_col1"]
+                                    <-Map 11 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_125]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_124] (rows=12174 width=1119)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_123] (rows=12174 width=1119)
+                                            predicate:((d_qoy < 4) and (d_year = 1999) and d_date_sk is not null)
+                                            TableScan [TS_12] (rows=73049 width=1119)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
+                                    <-Map 9 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_122]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_121] (rows=575995635 width=88)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_120] (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 13 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_133]
+                                PartitionCols:_col0
+                                Select Operator [SEL_132] (rows=79201469 width=135)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_131] (rows=79201469 width=135)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 12 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_30]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_123] (rows=12174 width=1119)
-                                        Output:["_col0"]
-                                        Filter Operator [FIL_122] (rows=12174 width=1119)
-                                          predicate:((d_qoy < 4) and (d_year = 1999) and d_date_sk is not null)
-                                          TableScan [TS_12] (rows=73049 width=1119)
-                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
-                                  <-Map 9 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_121]
+                                      Group By Operator [GBY_29] (rows=158402938 width=135)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_108] (rows=158402938 width=135)
+                                          Conds:RS_130._col0=RS_126._col0(Inner),Output:["_col1"]
+                                        <-Map 11 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_126]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_124]
+                                        <-Map 16 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_130]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_129] (rows=144002668 width=135)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_128] (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 15 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_139]
+                                PartitionCols:_col0
+                                Select Operator [SEL_138] (rows=158394413 width=135)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_137] (rows=158394413 width=135)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 14 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_44]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_120] (rows=575995635 width=88)
-                                        Output:["_col0","_col1"]
-                                        Filter Operator [FIL_119] (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 13 [ONE_TO_ONE_EDGE] vectorized
-                            FORWARD [RS_132]
-                              PartitionCols:_col0
-                              Select Operator [SEL_131] (rows=79201469 width=135)
-                                Output:["_col0","_col1"]
-                                Group By Operator [GBY_130] (rows=79201469 width=135)
-                                  Output:["_col0"],keys:KEY._col0
-                                <-Reducer 12 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_30]
+                                      Group By Operator [GBY_43] (rows=316788826 width=135)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_109] (rows=316788826 width=135)
+                                          Conds:RS_136._col0=RS_127._col0(Inner),Output:["_col1"]
+                                        <-Map 11 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_127]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_124]
+                                        <-Map 17 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_136]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_135] (rows=287989836 width=135)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_134] (rows=287989836 width=135)
+                                                predicate:(cs_ship_customer_sk is not null and cs_sold_date_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_ship_customer_sk"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_55]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_106] (rows=96800003 width=860)
+                                  Conds:RS_50._col1=RS_119._col0(Inner),Output:["_col0","_col4","_col6","_col7","_col8","_col9","_col10"]
+                                <-Map 8 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_119]
                                     PartitionCols:_col0
-                                    Group By Operator [GBY_29] (rows=158402938 width=135)
-                                      Output:["_col0"],keys:_col1
-                                      Merge Join Operator [MERGEJOIN_107] (rows=158402938 width=135)
-                                        Conds:RS_129._col0=RS_125._col0(Inner),Output:["_col1"]
-                                      <-Map 11 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_125]
-                                          PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_123]
-                                      <-Map 16 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_129]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_128] (rows=144002668 width=135)
-                                            Output:["_col0","_col1"]
-                                            Filter Operator [FIL_127] (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 15 [ONE_TO_ONE_EDGE] vectorized
-                            FORWARD [RS_138]
-                              PartitionCols:_col0
-                              Select Operator [SEL_137] (rows=158394413 width=135)
-                                Output:["_col0","_col1"]
-                                Group By Operator [GBY_136] (rows=158394413 width=135)
-                                  Output:["_col0"],keys:KEY._col0
-                                <-Reducer 14 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_44]
-                                    PartitionCols:_col0
-                                    Group By Operator [GBY_43] (rows=316788826 width=135)
-                                      Output:["_col0"],keys:_col1
-                                      Merge Join Operator [MERGEJOIN_108] (rows=316788826 width=135)
-                                        Conds:RS_135._col0=RS_126._col0(Inner),Output:["_col1"]
-                                      <-Map 11 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_126]
-                                          PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_123]
-                                      <-Map 17 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_135]
-                                          PartitionCols:_col0
-                                          Select Operator [SEL_134] (rows=287989836 width=135)
-                                            Output:["_col0","_col1"]
-                                            Filter Operator [FIL_133] (rows=287989836 width=135)
-                                              predicate:(cs_ship_customer_sk is not null and cs_sold_date_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_ship_customer_sk"]
-                          <-Reducer 3 [SIMPLE_EDGE]
-                            SHUFFLE [RS_55]
-                              PartitionCols:_col0
-                              Merge Join Operator [MERGEJOIN_105] (rows=96800003 width=860)
-                                Conds:RS_50._col1=RS_118._col0(Inner),Output:["_col0","_col4","_col6","_col7","_col8","_col9","_col10"]
-                              <-Map 8 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_118]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_117] (rows=1861800 width=385)
-                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                    Filter Operator [FIL_116] (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_dep_count","cd_dep_employed_count","cd_dep_college_count"]
-                              <-Reducer 2 [SIMPLE_EDGE]
-                                SHUFFLE [RS_50]
-                                  PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_104] (rows=88000001 width=860)
-                                    Conds:RS_112._col2=RS_115._col0(Inner),Output:["_col0","_col1","_col4"]
-                                  <-Map 1 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_112]
-                                      PartitionCols:_col2
-                                      Select Operator [SEL_111] (rows=80000000 width=860)
-                                        Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_110] (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 7 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_115]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_114] (rows=40000000 width=1014)
-                                        Output:["_col0","_col1"]
-                                        Filter Operator [FIL_113] (rows=40000000 width=1014)
-                                          predicate: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"]
+                                    Select Operator [SEL_118] (rows=1861800 width=385)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                      Filter Operator [FIL_117] (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_dep_count","cd_dep_employed_count","cd_dep_college_count"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_50]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_105] (rows=88000001 width=860)
+                                      Conds:RS_113._col2=RS_116._col0(Inner),Output:["_col0","_col1","_col4"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_113]
+                                        PartitionCols:_col2
+                                        Select Operator [SEL_112] (rows=80000000 width=860)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_111] (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 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_116]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_115] (rows=40000000 width=1014)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_114] (rows=40000000 width=1014)
+                                            predicate: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/query37.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query37.q.out b/ql/src/test/results/clientpositive/perf/tez/query37.q.out
index 6112a5a..8841bfd 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query37.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query37.q.out
@@ -43,61 +43,63 @@ Stage-0
     limit:100
     Stage-1
       Reducer 4 vectorized
-      File Output Operator [FS_61]
-        Limit [LIM_60] (rows=100 width=135)
+      File Output Operator [FS_62]
+        Limit [LIM_61] (rows=100 width=135)
           Number of rows:100
-          Select Operator [SEL_59] (rows=316788826 width=135)
+          Select Operator [SEL_60] (rows=316788826 width=135)
             Output:["_col0","_col1","_col2"]
           <-Reducer 3 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_58]
-              Group By Operator [GBY_57] (rows=316788826 width=135)
+            SHUFFLE [RS_59]
+              Group By Operator [GBY_58] (rows=316788826 width=135)
                 Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
               <-Reducer 2 [SIMPLE_EDGE]
                 SHUFFLE [RS_22]
                   PartitionCols:_col0, _col1, _col2
                   Group By Operator [GBY_21] (rows=633577652 width=135)
                     Output:["_col0","_col1","_col2"],keys:_col2, _col3, _col4
-                    Merge Join Operator [MERGEJOIN_44] (rows=633577652 width=135)
-                      Conds:RS_47._col0=RS_50._col0(Inner),RS_50._col0=RS_18._col1(Inner),Output:["_col2","_col3","_col4"]
-                    <-Map 1 [SIMPLE_EDGE] vectorized
-                      SHUFFLE [RS_47]
-                        PartitionCols:_col0
-                        Select Operator [SEL_46] (rows=287989836 width=135)
-                          Output:["_col0"]
-                          Filter Operator [FIL_45] (rows=287989836 width=135)
-                            predicate:cs_item_sk is not null
-                            TableScan [TS_0] (rows=287989836 width=135)
-                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_item_sk"]
-                    <-Map 5 [SIMPLE_EDGE] vectorized
-                      SHUFFLE [RS_50]
-                        PartitionCols:_col0
-                        Select Operator [SEL_49] (rows=25666 width=1436)
-                          Output:["_col0","_col1","_col2","_col3"]
-                          Filter Operator [FIL_48] (rows=25666 width=1436)
-                            predicate:((i_manufact_id) IN (678, 964, 918, 849) and i_current_price BETWEEN 22 AND 52 and i_item_sk is not null)
-                            TableScan [TS_3] (rows=462000 width=1436)
-                              default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_manufact_id"]
-                    <-Reducer 7 [SIMPLE_EDGE]
-                      SHUFFLE [RS_18]
-                        PartitionCols:_col1
-                        Merge Join Operator [MERGEJOIN_43] (rows=4593600 width=15)
-                          Conds:RS_53._col0=RS_56._col0(Inner),Output:["_col1"]
-                        <-Map 6 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_53]
-                            PartitionCols:_col0
-                            Select Operator [SEL_52] (rows=4176000 width=15)
-                              Output:["_col0","_col1"]
-                              Filter Operator [FIL_51] (rows=4176000 width=15)
-                                predicate:(inv_date_sk is not null and inv_item_sk is not null and inv_quantity_on_hand BETWEEN 100 AND 500)
-                                TableScan [TS_6] (rows=37584000 width=15)
-                                  default@inventory,inventory,Tbl:COMPLETE,Col:NONE,Output:["inv_date_sk","inv_item_sk","inv_quantity_on_hand"]
-                        <-Map 8 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_56]
-                            PartitionCols:_col0
-                            Select Operator [SEL_55] (rows=8116 width=1119)
-                              Output:["_col0"]
-                              Filter Operator [FIL_54] (rows=8116 width=1119)
-                                predicate:(CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-06-02 00:00:00' AND TIMESTAMP'2001-08-01 00:00:00' 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_date"]
+                    Top N Key Operator [TNK_43] (rows=633577652 width=135)
+                      keys:_col2, _col3, _col4,sort order:+++,top n:100
+                      Merge Join Operator [MERGEJOIN_45] (rows=633577652 width=135)
+                        Conds:RS_48._col0=RS_51._col0(Inner),RS_51._col0=RS_18._col1(Inner),Output:["_col2","_col3","_col4"]
+                      <-Map 1 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_48]
+                          PartitionCols:_col0
+                          Select Operator [SEL_47] (rows=287989836 width=135)
+                            Output:["_col0"]
+                            Filter Operator [FIL_46] (rows=287989836 width=135)
+                              predicate:cs_item_sk is not null
+                              TableScan [TS_0] (rows=287989836 width=135)
+                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_item_sk"]
+                      <-Map 5 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_51]
+                          PartitionCols:_col0
+                          Select Operator [SEL_50] (rows=25666 width=1436)
+                            Output:["_col0","_col1","_col2","_col3"]
+                            Filter Operator [FIL_49] (rows=25666 width=1436)
+                              predicate:((i_manufact_id) IN (678, 964, 918, 849) and i_current_price BETWEEN 22 AND 52 and i_item_sk is not null)
+                              TableScan [TS_3] (rows=462000 width=1436)
+                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_manufact_id"]
+                      <-Reducer 7 [SIMPLE_EDGE]
+                        SHUFFLE [RS_18]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_44] (rows=4593600 width=15)
+                            Conds:RS_54._col0=RS_57._col0(Inner),Output:["_col1"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_54]
+                              PartitionCols:_col0
+                              Select Operator [SEL_53] (rows=4176000 width=15)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_52] (rows=4176000 width=15)
+                                  predicate:(inv_date_sk is not null and inv_item_sk is not null and inv_quantity_on_hand BETWEEN 100 AND 500)
+                                  TableScan [TS_6] (rows=37584000 width=15)
+                                    default@inventory,inventory,Tbl:COMPLETE,Col:NONE,Output:["inv_date_sk","inv_item_sk","inv_quantity_on_hand"]
+                          <-Map 8 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_57]
+                              PartitionCols:_col0
+                              Select Operator [SEL_56] (rows=8116 width=1119)
+                                Output:["_col0"]
+                                Filter Operator [FIL_55] (rows=8116 width=1119)
+                                  predicate:(CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-06-02 00:00:00' AND TIMESTAMP'2001-08-01 00:00:00' 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_date"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query40.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query40.q.out b/ql/src/test/results/clientpositive/perf/tez/query40.q.out
index 4c48bd8..2f73230 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query40.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query40.q.out
@@ -67,82 +67,84 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_78]
-        Limit [LIM_77] (rows=100 width=135)
+      File Output Operator [FS_79]
+        Limit [LIM_78] (rows=100 width=135)
           Number of rows:100
-          Select Operator [SEL_76] (rows=210822976 width=135)
+          Select Operator [SEL_77] (rows=210822976 width=135)
             Output:["_col0","_col1","_col2","_col3"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_75]
-              Group By Operator [GBY_74] (rows=210822976 width=135)
+            SHUFFLE [RS_76]
+              Group By Operator [GBY_75] (rows=210822976 width=135)
                 Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1
               <-Reducer 5 [SIMPLE_EDGE]
                 SHUFFLE [RS_30]
                   PartitionCols:_col0, _col1
                   Group By Operator [GBY_29] (rows=421645953 width=135)
                     Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col0, _col1
-                    Select Operator [SEL_27] (rows=421645953 width=135)
-                      Output:["_col0","_col1","_col2","_col3"]
-                      Merge Join Operator [MERGEJOIN_58] (rows=421645953 width=135)
-                        Conds:RS_24._col1=RS_73._col0(Inner),Output:["_col4","_col7","_col9","_col11","_col14"]
-                      <-Map 11 [SIMPLE_EDGE] vectorized
-                        SHUFFLE [RS_73]
-                          PartitionCols:_col0
-                          Select Operator [SEL_72] (rows=27 width=1029)
-                            Output:["_col0","_col1"]
-                            Filter Operator [FIL_71] (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_state"]
-                      <-Reducer 4 [SIMPLE_EDGE]
-                        SHUFFLE [RS_24]
-                          PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_57] (rows=383314495 width=135)
-                            Conds:RS_21._col2=RS_70._col0(Inner),Output:["_col1","_col4","_col7","_col9","_col11"]
-                          <-Map 10 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_70]
-                              PartitionCols:_col0
-                              Select Operator [SEL_69] (rows=51333 width=1436)
-                                Output:["_col0","_col1"]
-                                Filter Operator [FIL_68] (rows=51333 width=1436)
-                                  predicate:(i_current_price BETWEEN 0.99 AND 1.49 and i_item_sk is not null)
-                                  TableScan [TS_9] (rows=462000 width=1436)
-                                    default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_current_price"]
-                          <-Reducer 3 [SIMPLE_EDGE]
-                            SHUFFLE [RS_21]
-                              PartitionCols:_col2
-                              Merge Join Operator [MERGEJOIN_56] (rows=348467716 width=135)
-                                Conds:RS_18._col0=RS_67._col0(Inner),Output:["_col1","_col2","_col4","_col7","_col9"]
-                              <-Map 9 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_67]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_66] (rows=8116 width=1119)
-                                    Output:["_col0","_col1"]
-                                    Filter Operator [FIL_65] (rows=8116 width=1119)
-                                      predicate:(CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-03-09 00:00:00' AND TIMESTAMP'1998-05-08 00:00:00' 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_date"]
-                              <-Reducer 2 [SIMPLE_EDGE]
-                                SHUFFLE [RS_18]
-                                  PartitionCols:_col0
-                                  Merge Join Operator [MERGEJOIN_55] (rows=316788826 width=135)
-                                    Conds:RS_61._col2, _col3=RS_64._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col7"]
-                                  <-Map 1 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_61]
-                                      PartitionCols:_col2, _col3
-                                      Select Operator [SEL_60] (rows=287989836 width=135)
-                                        Output:["_col0","_col1","_col2","_col3","_col4"]
-                                        Filter Operator [FIL_59] (rows=287989836 width=135)
-                                          predicate:(cs_item_sk is not null and cs_sold_date_sk is not null and cs_warehouse_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_warehouse_sk","cs_item_sk","cs_order_number","cs_sales_price"]
-                                  <-Map 8 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_64]
-                                      PartitionCols:_col0, _col1
-                                      Select Operator [SEL_63] (rows=28798881 width=106)
-                                        Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_62] (rows=28798881 width=106)
-                                          predicate:cr_item_sk is not null
-                                          TableScan [TS_3] (rows=28798881 width=106)
-                                            default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_item_sk","cr_order_number","cr_refunded_cash"]
+                    Top N Key Operator [TNK_55] (rows=421645953 width=135)
+                      keys:_col0, _col1,sort order:++,top n:100
+                      Select Operator [SEL_27] (rows=421645953 width=135)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Merge Join Operator [MERGEJOIN_59] (rows=421645953 width=135)
+                          Conds:RS_24._col1=RS_74._col0(Inner),Output:["_col4","_col7","_col9","_col11","_col14"]
+                        <-Map 11 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_74]
+                            PartitionCols:_col0
+                            Select Operator [SEL_73] (rows=27 width=1029)
+                              Output:["_col0","_col1"]
+                              Filter Operator [FIL_72] (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_state"]
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_24]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_58] (rows=383314495 width=135)
+                              Conds:RS_21._col2=RS_71._col0(Inner),Output:["_col1","_col4","_col7","_col9","_col11"]
+                            <-Map 10 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_71]
+                                PartitionCols:_col0
+                                Select Operator [SEL_70] (rows=51333 width=1436)
+                                  Output:["_col0","_col1"]
+                                  Filter Operator [FIL_69] (rows=51333 width=1436)
+                                    predicate:(i_current_price BETWEEN 0.99 AND 1.49 and i_item_sk is not null)
+                                    TableScan [TS_9] (rows=462000 width=1436)
+                                      default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id","i_current_price"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_21]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_57] (rows=348467716 width=135)
+                                  Conds:RS_18._col0=RS_68._col0(Inner),Output:["_col1","_col2","_col4","_col7","_col9"]
+                                <-Map 9 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_68]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_67] (rows=8116 width=1119)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_66] (rows=8116 width=1119)
+                                        predicate:(CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-03-09 00:00:00' AND TIMESTAMP'1998-05-08 00:00:00' 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_date"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_18]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_56] (rows=316788826 width=135)
+                                      Conds:RS_62._col2, _col3=RS_65._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col7"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_62]
+                                        PartitionCols:_col2, _col3
+                                        Select Operator [SEL_61] (rows=287989836 width=135)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_60] (rows=287989836 width=135)
+                                            predicate:(cs_item_sk is not null and cs_sold_date_sk is not null and cs_warehouse_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_warehouse_sk","cs_item_sk","cs_order_number","cs_sales_price"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_65]
+                                        PartitionCols:_col0, _col1
+                                        Select Operator [SEL_64] (rows=28798881 width=106)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_63] (rows=28798881 width=106)
+                                            predicate:cr_item_sk is not null
+                                            TableScan [TS_3] (rows=28798881 width=106)
+                                              default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_item_sk","cr_order_number","cr_refunded_cash"]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/cc294d32/ql/src/test/results/clientpositive/perf/tez/query43.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query43.q.out b/ql/src/test/results/clientpositive/perf/tez/query43.q.out
index 0086a94..69b4e5f 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query43.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query43.q.out
@@ -47,54 +47,56 @@ Stage-0
     limit:100
     Stage-1
       Reducer 5 vectorized
-      File Output Operator [FS_48]
-        Limit [LIM_47] (rows=100 width=88)
+      File Output Operator [FS_49]
+        Limit [LIM_48] (rows=100 width=88)
           Number of rows:100
-          Select Operator [SEL_46] (rows=348477374 width=88)
+          Select Operator [SEL_47] (rows=348477374 width=88)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
           <-Reducer 4 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_45]
-              Group By Operator [GBY_44] (rows=348477374 width=88)
+            SHUFFLE [RS_46]
+              Group By Operator [GBY_45] (rows=348477374 width=88)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)"],keys:KEY._col0, KEY._col1
               <-Reducer 3 [SIMPLE_EDGE]
                 SHUFFLE [RS_18]
                   PartitionCols:_col0, _col1
                   Group By Operator [GBY_17] (rows=696954748 width=88)
                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
-                    Select Operator [SEL_15] (rows=696954748 width=88)
-                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
-                      Merge Join Operator [MERGEJOIN_34] (rows=696954748 width=88)
-                        Conds:RS_12._col1=RS_43._col0(Inner),Output:["_col2","_col5","_col7","_col8"]
-                      <-Map 7 [SIMPLE_EDGE] vectorized
-                        SHUFFLE [RS_43]
-                          PartitionCols:_col0
-                          Select Operator [SEL_42] (rows=852 width=1910)
-                            Output:["_col0","_col1","_col2"]
-                            Filter Operator [FIL_41] (rows=852 width=1910)
-                              predicate:((s_gmt_offset = -6) and s_store_sk is not null)
-                              TableScan [TS_6] (rows=1704 width=1910)
-                                default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name","s_gmt_offset"]
-                      <-Reducer 2 [SIMPLE_EDGE]
-                        SHUFFLE [RS_12]
-                          PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_33] (rows=633595212 width=88)
-                            Conds:RS_37._col0=RS_40._col0(Inner),Output:["_col1","_col2","_col5"]
-                          <-Map 1 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_37]
-                              PartitionCols:_col0
-                              Select Operator [SEL_36] (rows=575995635 width=88)
-                                Output:["_col0","_col1","_col2"]
-                                Filter Operator [FIL_35] (rows=575995635 width=88)
-                                  predicate:(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_store_sk","ss_sales_price"]
-                          <-Map 6 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_40]
-                              PartitionCols:_col0
-                              Select Operator [SEL_39] (rows=36524 width=1119)
-                                Output:["_col0","_col2"]
-                                Filter Operator [FIL_38] (rows=36524 width=1119)
-                                  predicate:((d_year = 1998) and d_date_sk is not null)
-                                  TableScan [TS_3] (rows=73049 width=1119)
-                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_day_name"]
+                    Top N Key Operator [TNK_33] (rows=696954748 width=88)
+                      keys:_col0, _col1,sort order:++,top n:100
+                      Select Operator [SEL_15] (rows=696954748 width=88)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                        Merge Join Operator [MERGEJOIN_35] (rows=696954748 width=88)
+                          Conds:RS_12._col1=RS_44._col0(Inner),Output:["_col2","_col5","_col7","_col8"]
+                        <-Map 7 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_44]
+                            PartitionCols:_col0
+                            Select Operator [SEL_43] (rows=852 width=1910)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_42] (rows=852 width=1910)
+                                predicate:((s_gmt_offset = -6) and s_store_sk is not null)
+                                TableScan [TS_6] (rows=1704 width=1910)
+                                  default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_store_sk","s_store_id","s_store_name","s_gmt_offset"]
+                        <-Reducer 2 [SIMPLE_EDGE]
+                          SHUFFLE [RS_12]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_34] (rows=633595212 width=88)
+                              Conds:RS_38._col0=RS_41._col0(Inner),Output:["_col1","_col2","_col5"]
+                            <-Map 1 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_38]
+                                PartitionCols:_col0
+                                Select Operator [SEL_37] (rows=575995635 width=88)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_36] (rows=575995635 width=88)
+                                    predicate:(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_store_sk","ss_sales_price"]
+                            <-Map 6 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_41]
+                                PartitionCols:_col0
+                                Select Operator [SEL_40] (rows=36524 width=1119)
+                                  Output:["_col0","_col2"]
+                                  Filter Operator [FIL_39] (rows=36524 width=1119)
+                                    predicate:((d_year = 1998) and d_date_sk is not null)
+                                    TableScan [TS_3] (rows=73049 width=1119)
+                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_day_name"]