http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/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
new file mode 100644
index 0000000..c6a1905
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query27.q.out
@@ -0,0 +1,140 @@
+PREHOOK: query: explain
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 10 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 11 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7
+      File Output Operator [FS_36]
+        Limit [LIM_35] (rows=100 width=88)
+          Number of rows:100
+          Select Operator [SEL_34] (rows=1264972921 width=88)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_33]
+              Select Operator [SEL_32] (rows=1264972921 width=88)
+                
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                Group By Operator [GBY_31] (rows=1264972921 width=88)
+                  
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["avg(VALUE._col0)","avg(VALUE._col1)","avg(VALUE._col2)","avg(VALUE._col3)"],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"],aggregations:["avg(_col2)","avg(_col3)","avg(_col4)","avg(_col5)"],keys:_col0,
 _col1, 0
+                      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_25._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col15","_col17"]
+                        <-Map 11 [SIMPLE_EDGE]
+                          SHUFFLE [RS_25]
+                            PartitionCols:_col0
+                            Select Operator [SEL_14] (rows=462000 width=1436)
+                              Output:["_col0","_col1"]
+                              Filter Operator [FIL_55] (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_22._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col15"]
+                            <-Map 10 [SIMPLE_EDGE]
+                              SHUFFLE [RS_22]
+                                PartitionCols:_col0
+                                Select Operator [SEL_11] (rows=852 width=1910)
+                                  Output:["_col0","_col1"]
+                                  Filter Operator [FIL_54] (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_19._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                <-Map 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_19]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_8] (rows=36524 
width=1119)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_53] (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_15._col2=RS_16._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 1 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_15]
+                                        PartitionCols:_col2
+                                        Select Operator [SEL_2] 
(rows=575995635 width=88)
+                                          
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_51] 
(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]
+                                      SHUFFLE [RS_16]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_5] (rows=232725 
width=385)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_52] 
(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"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query28.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query28.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query28.q.out
new file mode 100644
index 0000000..33dc1ae
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query28.q.out
@@ -0,0 +1,256 @@
+Warning: Shuffle Join MERGEJOIN[94][tables = [$hdt$_0, $hdt$_1, $hdt$_2, 
$hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 4' is a cross product
+PREHOOK: query: explain
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Map 1 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 1 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 10 (CUSTOM_SIMPLE_EDGE), Reducer 12 (CUSTOM_SIMPLE_EDGE), 
Reducer 14 (CUSTOM_SIMPLE_EDGE), Reducer 3 (CUSTOM_SIMPLE_EDGE), Reducer 6 
(CUSTOM_SIMPLE_EDGE), Reducer 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Map 1 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Map 1 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 1 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4
+      File Output Operator [FS_51]
+        Limit [LIM_50] (rows=1 width=3505)
+          Number of rows:100
+          Select Operator [SEL_49] (rows=1 width=3505)
+            
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"]
+            Merge Join Operator [MERGEJOIN_94] (rows=1 width=3505)
+              
Conds:(Inner),(Inner),(Inner),(Inner),(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"]
+            <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_45]
+                Group By Operator [GBY_81] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 9 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_80]
+                    Group By Operator [GBY_79] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_78] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_77]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_76] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_23] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_55] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 142 AND 152 
or ss_coupon_amt BETWEEN 3054 AND 4054 or ss_wholesale_cost BETWEEN 80 AND 100) 
and ss_quantity BETWEEN 16 AND 20)
+                                TableScan [TS_0] (rows=575995635 width=88)
+                                  
default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_quantity","ss_wholesale_cost","ss_list_price","ss_coupon_amt"]
+            <-Reducer 12 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_46]
+                Group By Operator [GBY_87] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 11 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_86]
+                    Group By Operator [GBY_85] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_84] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_83]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_82] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_30] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_56] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 66 AND 76 or 
ss_coupon_amt BETWEEN 920 AND 1920 or ss_wholesale_cost BETWEEN 4 AND 24) and 
ss_quantity BETWEEN 11 AND 15)
+                                 Please refer to the previous TableScan [TS_0]
+            <-Reducer 14 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_47]
+                Group By Operator [GBY_93] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 13 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_92]
+                    Group By Operator [GBY_91] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_90] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_89]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_88] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_37] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_57] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 91 AND 101 
or ss_coupon_amt BETWEEN 1430 AND 2430 or ss_wholesale_cost BETWEEN 32 AND 52) 
and ss_quantity BETWEEN 6 AND 10)
+                                 Please refer to the previous TableScan [TS_0]
+            <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_42]
+                Group By Operator [GBY_63] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_62]
+                    Group By Operator [GBY_61] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_60] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_59]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_58] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_2] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_52] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 11 AND 21 or 
ss_coupon_amt BETWEEN 460 AND 1460 or ss_wholesale_cost BETWEEN 14 AND 34) and 
ss_quantity BETWEEN 0 AND 5)
+                                 Please refer to the previous TableScan [TS_0]
+            <-Reducer 6 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_43]
+                Group By Operator [GBY_69] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_68]
+                    Group By Operator [GBY_67] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_66] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_65]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_64] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_9] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_53] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 28 AND 38 or 
ss_coupon_amt BETWEEN 2513 AND 3513 or ss_wholesale_cost BETWEEN 42 AND 62) and 
ss_quantity BETWEEN 26 AND 30)
+                                 Please refer to the previous TableScan [TS_0]
+            <-Reducer 8 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_44]
+                Group By Operator [GBY_75] (rows=1 width=584)
+                  
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                <-Reducer 7 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_74]
+                    Group By Operator [GBY_73] (rows=1 width=584)
+                      
Output:["_col0","_col1","_col2"],aggregations:["avg(_col1)","count(_col2)","count(_col0)"]
+                      Group By Operator [GBY_72] (rows=21333171 width=88)
+                        
Output:["_col0","_col1","_col2"],aggregations:["avg(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                      <-Map 1 [SIMPLE_EDGE]
+                        SHUFFLE [RS_71]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_70] (rows=21333171 width=88)
+                            
Output:["_col0","_col1","_col2"],aggregations:["avg(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                            Select Operator [SEL_16] (rows=21333171 width=88)
+                              Output:["ss_list_price"]
+                              Filter Operator [FIL_54] (rows=21333171 width=88)
+                                predicate:((ss_list_price BETWEEN 135 AND 145 
or ss_coupon_amt BETWEEN 14180 AND 15180 or ss_wholesale_cost BETWEEN 38 AND 
58) and ss_quantity BETWEEN 21 AND 25)
+                                 Please refer to the previous TableScan [TS_0]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/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
new file mode 100644
index 0000000..81abe01
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query29.q.out
@@ -0,0 +1,230 @@
+PREHOOK: query: explain
+select   
+     i_item_id
+    ,i_item_desc
+    ,s_store_id
+    ,s_store_name
+    ,sum(ss_quantity)        as store_sales_quantity
+    ,sum(sr_return_quantity) as store_returns_quantity
+    ,sum(cs_quantity)        as catalog_sales_quantity
+ from
+    store_sales
+   ,store_returns
+   ,catalog_sales
+   ,date_dim             d1
+   ,date_dim             d2
+   ,date_dim             d3
+   ,store
+   ,item
+ where
+     d1.d_moy               = 4 
+ and d1.d_year              = 1999
+ and d1.d_date_sk           = ss_sold_date_sk
+ and i_item_sk              = ss_item_sk
+ and s_store_sk             = ss_store_sk
+ and ss_customer_sk         = sr_customer_sk
+ and ss_item_sk             = sr_item_sk
+ and ss_ticket_number       = sr_ticket_number
+ and sr_returned_date_sk    = d2.d_date_sk
+ and d2.d_moy               between 4 and  4 + 3 
+ and d2.d_year              = 1999
+ and sr_customer_sk         = cs_bill_customer_sk
+ and sr_item_sk             = cs_item_sk
+ and cs_sold_date_sk        = d3.d_date_sk     
+ and d3.d_year              in (1999,1999+1,1999+2)
+ group by
+    i_item_id
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ order by
+    i_item_id 
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select   
+     i_item_id
+    ,i_item_desc
+    ,s_store_id
+    ,s_store_name
+    ,sum(ss_quantity)        as store_sales_quantity
+    ,sum(sr_return_quantity) as store_returns_quantity
+    ,sum(cs_quantity)        as catalog_sales_quantity
+ from
+    store_sales
+   ,store_returns
+   ,catalog_sales
+   ,date_dim             d1
+   ,date_dim             d2
+   ,date_dim             d3
+   ,store
+   ,item
+ where
+     d1.d_moy               = 4 
+ and d1.d_year              = 1999
+ and d1.d_date_sk           = ss_sold_date_sk
+ and i_item_sk              = ss_item_sk
+ and s_store_sk             = ss_store_sk
+ and ss_customer_sk         = sr_customer_sk
+ and ss_item_sk             = sr_item_sk
+ and ss_ticket_number       = sr_ticket_number
+ and sr_returned_date_sk    = d2.d_date_sk
+ and d2.d_moy               between 4 and  4 + 3 
+ and d2.d_year              = 1999
+ and sr_customer_sk         = cs_bill_customer_sk
+ and sr_item_sk             = cs_item_sk
+ and cs_sold_date_sk        = d3.d_date_sk     
+ and d3.d_year              in (1999,1999+1,1999+2)
+ group by
+    i_item_id
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ order by
+    i_item_id 
+   ,i_item_desc
+   ,s_store_id
+   ,s_store_name
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 15 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 16 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 11 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 8 <- Map 12 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 13 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5
+      File Output Operator [FS_55]
+        Limit [LIM_54] (rows=100 width=88)
+          Number of rows:100
+          Select Operator [SEL_53] (rows=463823414 width=88)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_52]
+              Group By Operator [GBY_50] (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_38._col0(Inner),Output:["_col5","_col10","_col11","_col13","_col18","_col19","_col21","_col22"]
+                          <-Map 16 [SIMPLE_EDGE]
+                            SHUFFLE [RS_38]
+                              PartitionCols:_col0
+                              Select Operator [SEL_27] (rows=1704 width=1910)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_92] (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_35._col0(Inner),Output:["_col3","_col5","_col10","_col11","_col13","_col18","_col19"]
+                              <-Map 15 [SIMPLE_EDGE]
+                                SHUFFLE [RS_35]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_24] (rows=462000 
width=1436)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_91] (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_18._col0=RS_19._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                      <-Map 12 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_17] (rows=4058 
width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_90] 
(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]
+                                        SHUFFLE [RS_18]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_14] 
(rows=57591150 width=77)
+                                            
Output:["_col0","_col1","_col2","_col3","_col4"]
+                                            Filter Operator [FIL_89] 
(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_28._col0=RS_29._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                      <-Map 12 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_29]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_11] (rows=18262 
width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_88] 
(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]
+                                        SHUFFLE [RS_28]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_8] 
(rows=575995635 width=88)
+                                            
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                            Filter Operator [FIL_87] 
(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_41._col0=RS_42._col0(Inner),Output:["_col1","_col2","_col3"]
+                        <-Map 1 [SIMPLE_EDGE]
+                          SHUFFLE [RS_41]
+                            PartitionCols:_col0
+                            Select Operator [SEL_2] (rows=287989836 width=135)
+                              Output:["_col0","_col1","_col2","_col3"]
+                              Filter Operator [FIL_85] (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]
+                          SHUFFLE [RS_42]
+                            PartitionCols:_col0
+                            Select Operator [SEL_5] (rows=36525 width=1119)
+                              Output:["_col0"]
+                              Filter Operator [FIL_86] (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/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query3.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query3.q.out
new file mode 100644
index 0000000..462f05d
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query3.q.out
@@ -0,0 +1,102 @@
+PREHOOK: query: explain
+select  dt.d_year 
+       ,item.i_brand_id brand_id 
+       ,item.i_brand brand
+       ,sum(ss_ext_sales_price) sum_agg
+ from  date_dim dt 
+      ,store_sales
+      ,item
+ where dt.d_date_sk = store_sales.ss_sold_date_sk
+   and store_sales.ss_item_sk = item.i_item_sk
+   and item.i_manufact_id = 436
+   and dt.d_moy=12
+ group by dt.d_year
+      ,item.i_brand
+      ,item.i_brand_id
+ order by dt.d_year
+         ,sum_agg desc
+         ,brand_id
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select  dt.d_year 
+       ,item.i_brand_id brand_id 
+       ,item.i_brand brand
+       ,sum(ss_ext_sales_price) sum_agg
+ from  date_dim dt 
+      ,store_sales
+      ,item
+ where dt.d_date_sk = store_sales.ss_sold_date_sk
+   and store_sales.ss_item_sk = item.i_item_sk
+   and item.i_manufact_id = 436
+   and dt.d_moy=12
+ group by dt.d_year
+      ,item.i_brand
+      ,item.i_brand_id
+ order by dt.d_year
+         ,sum_agg desc
+         ,brand_id
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 7 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5
+      File Output Operator [FS_24]
+        Limit [LIM_23] (rows=100 width=88)
+          Number of rows:100
+          Select Operator [SEL_22] (rows=348477374 width=88)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_21]
+              Group By Operator [GBY_18] (rows=348477374 width=88)
+                
Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1, KEY._col2
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_17]
+                  PartitionCols:_col0, _col1, _col2
+                  Group By Operator [GBY_16] (rows=696954748 width=88)
+                    
Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col8,
 _col4, _col5
+                    Merge Join Operator [MERGEJOIN_34] (rows=696954748 
width=88)
+                      
Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col2","_col4","_col5","_col8"]
+                    <-Map 7 [SIMPLE_EDGE]
+                      SHUFFLE [RS_13]
+                        PartitionCols:_col0
+                        Select Operator [SEL_8] (rows=36524 width=1119)
+                          Output:["_col0","_col1"]
+                          Filter Operator [FIL_32] (rows=36524 width=1119)
+                            predicate:((d_moy = 12) and d_date_sk is not null)
+                            TableScan [TS_6] (rows=73049 width=1119)
+                              
default@date_dim,dt,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                    <-Reducer 2 [SIMPLE_EDGE]
+                      SHUFFLE [RS_12]
+                        PartitionCols:_col0
+                        Merge Join Operator [MERGEJOIN_33] (rows=633595212 
width=88)
+                          
Conds:RS_9._col1=RS_10._col0(Inner),Output:["_col0","_col2","_col4","_col5"]
+                        <-Map 1 [SIMPLE_EDGE]
+                          SHUFFLE [RS_9]
+                            PartitionCols:_col1
+                            Select Operator [SEL_2] (rows=575995635 width=88)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_30] (rows=575995635 
width=88)
+                                predicate:(ss_item_sk is not null and 
ss_sold_date_sk is not null)
+                                TableScan [TS_0] (rows=575995635 width=88)
+                                  
default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                        <-Map 6 [SIMPLE_EDGE]
+                          SHUFFLE [RS_10]
+                            PartitionCols:_col0
+                            Select Operator [SEL_5] (rows=231000 width=1436)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_31] (rows=231000 width=1436)
+                                predicate:((i_manufact_id = 436) 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_brand_id","i_brand","i_manufact_id"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query30.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query30.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query30.q.out
new file mode 100644
index 0000000..93ce9cd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query30.q.out
@@ -0,0 +1,211 @@
+PREHOOK: query: explain
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+       sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  
c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+                         from customer_total_return ctr2 
+                         where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by 
c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+       sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  
c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+                         from customer_total_return ctr2 
+                         where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by 
c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 13 <- Map 11 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 6 <- Map 5 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 10 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Map 5 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4
+      File Output Operator [FS_66]
+        Limit [LIM_65] (rows=100 width=860)
+          Number of rows:100
+          Select Operator [SEL_64] (rows=96800003 width=860)
+            
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_63]
+              Select Operator [SEL_62] (rows=96800003 width=860)
+                
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                Merge Join Operator [MERGEJOIN_107] (rows=96800003 width=860)
+                  
Conds:RS_59._col0=RS_60._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col18"]
+                <-Reducer 2 [SIMPLE_EDGE]
+                  SHUFFLE [RS_59]
+                    PartitionCols:_col0
+                    Merge Join Operator [MERGEJOIN_101] (rows=88000001 
width=860)
+                      
Conds:RS_56._col2=RS_57._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                    <-Map 5 [SIMPLE_EDGE]
+                      SHUFFLE [RS_57]
+                        PartitionCols:_col0
+                        Select Operator [SEL_5] (rows=20000000 width=1014)
+                          Output:["_col0"]
+                          Filter Operator [FIL_94] (rows=20000000 width=1014)
+                            predicate:((ca_state = 'IL') and 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"]
+                    <-Map 1 [SIMPLE_EDGE]
+                      SHUFFLE [RS_56]
+                        PartitionCols:_col2
+                        Select Operator [SEL_2] (rows=80000000 width=860)
+                          
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                          Filter Operator [FIL_93] (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_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name","c_preferred_cust_flag","c_birth_day","c_birth_month","c_birth_year","c_birth_country","c_login","c_email_address","c_last_review_date"]
+                <-Reducer 8 [SIMPLE_EDGE]
+                  SHUFFLE [RS_60]
+                    PartitionCols:_col0
+                    Select Operator [SEL_55] (rows=8066666 width=1014)
+                      Output:["_col0","_col2"]
+                      Filter Operator [FIL_54] (rows=8066666 width=1014)
+                        predicate:(_col2 > CASE WHEN (_col4 is null) THEN 
(null) ELSE (_col3) END)
+                        Merge Join Operator [MERGEJOIN_106] (rows=24200000 
width=1014)
+                          
Conds:RS_51._col1=RS_52._col2(Inner),Output:["_col0","_col2","_col3","_col4"]
+                        <-Reducer 10 [SIMPLE_EDGE]
+                          SHUFFLE [RS_52]
+                            PartitionCols:_col2
+                            Select Operator [SEL_50] (rows=11000000 width=1014)
+                              Output:["_col0","_col1","_col2"]
+                              Group By Operator [GBY_49] (rows=11000000 
width=1014)
+                                
Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col0
+                                Select Operator [SEL_45] (rows=22000000 
width=1014)
+                                  Output:["_col0","_col2"]
+                                  Group By Operator [GBY_44] (rows=22000000 
width=1014)
+                                    
Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1
+                                  <-Reducer 9 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_43]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_42] 
(rows=44000000 width=1014)
+                                        
Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
+                                        Merge Join Operator [MERGEJOIN_105] 
(rows=44000000 width=1014)
+                                          
Conds:RS_38._col2=RS_39._col0(Inner),Output:["_col1","_col3","_col7"]
+                                        <-Map 5 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_39]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_34] 
(rows=40000000 width=1014)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_100] 
(rows=40000000 width=1014)
+                                                predicate:(ca_address_sk is 
not null and ca_state is not null)
+                                                 Please refer to the previous 
TableScan [TS_3]
+                                        <-Reducer 13 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_38]
+                                            PartitionCols:_col2
+                                            Merge Join Operator 
[MERGEJOIN_104] (rows=15838314 width=92)
+                                              
Conds:RS_35._col0=RS_36._col0(Inner),Output:["_col1","_col2","_col3"]
+                                            <-Map 11 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_35]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_28] 
(rows=14398467 width=92)
+                                                  
Output:["_col0","_col1","_col2","_col3"]
+                                                  Filter Operator [FIL_98] 
(rows=14398467 width=92)
+                                                    
predicate:(wr_returned_date_sk is not null and wr_returning_addr_sk is not null)
+                                                    TableScan [TS_6] 
(rows=14398467 width=92)
+                                                      
default@web_returns,web_returns,Tbl:COMPLETE,Col:NONE,Output:["wr_returned_date_sk","wr_returning_customer_sk","wr_returning_addr_sk","wr_return_amt"]
+                                            <-Map 14 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_36]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_11] 
(rows=36524 width=1119)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_96] 
(rows=36524 width=1119)
+                                                    predicate:((d_year = 2002) 
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"]
+                        <-Reducer 7 [SIMPLE_EDGE]
+                          SHUFFLE [RS_51]
+                            PartitionCols:_col1
+                            Select Operator [SEL_25] (rows=22000000 width=1014)
+                              Output:["_col0","_col1","_col2"]
+                              Group By Operator [GBY_24] (rows=22000000 
width=1014)
+                                
Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1
+                              <-Reducer 6 [SIMPLE_EDGE]
+                                SHUFFLE [RS_23]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_22] (rows=44000000 
width=1014)
+                                    
Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
+                                    Merge Join Operator [MERGEJOIN_103] 
(rows=44000000 width=1014)
+                                      
Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col1","_col3","_col7"]
+                                    <-Map 5 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_19]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_14] 
(rows=40000000 width=1014)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_97] 
(rows=40000000 width=1014)
+                                            predicate:ca_address_sk is not null
+                                             Please refer to the previous 
TableScan [TS_3]
+                                    <-Reducer 12 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_18]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_102] 
(rows=15838314 width=92)
+                                          
Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 11 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_15]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_8] 
(rows=14398467 width=92)
+                                              
Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_95] 
(rows=14398467 width=92)
+                                                predicate:(wr_returned_date_sk 
is not null and wr_returning_addr_sk is not null and wr_returning_customer_sk 
is not null)
+                                                 Please refer to the previous 
TableScan [TS_6]
+                                        <-Map 14 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_16]
+                                            PartitionCols:_col0
+                                             Please refer to the previous 
Select Operator [SEL_11]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query31.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query31.q.out
new file mode 100644
index 0000000..4ccc6a4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query31.q.out
@@ -0,0 +1,358 @@
+PREHOOK: query: explain
+with ss as
+ (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales
+ from store_sales,date_dim,customer_address
+ where ss_sold_date_sk = d_date_sk
+  and ss_addr_sk=ca_address_sk
+ group by ca_county,d_qoy, d_year),
+ ws as
+ (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales
+ from web_sales,date_dim,customer_address
+ where ws_sold_date_sk = d_date_sk
+  and ws_bill_addr_sk=ca_address_sk
+ group by ca_county,d_qoy, d_year)
+ select /* tt */
+        ss1.ca_county
+       ,ss1.d_year
+       ,ws2.web_sales/ws1.web_sales web_q1_q2_increase
+       ,ss2.store_sales/ss1.store_sales store_q1_q2_increase
+       ,ws3.web_sales/ws2.web_sales web_q2_q3_increase
+       ,ss3.store_sales/ss2.store_sales store_q2_q3_increase
+ from
+        ss ss1
+       ,ss ss2
+       ,ss ss3
+       ,ws ws1
+       ,ws ws2
+       ,ws ws3
+ where
+    ss1.d_qoy = 1
+    and ss1.d_year = 2000
+    and ss1.ca_county = ss2.ca_county
+    and ss2.d_qoy = 2
+    and ss2.d_year = 2000
+ and ss2.ca_county = ss3.ca_county
+    and ss3.d_qoy = 3
+    and ss3.d_year = 2000
+    and ss1.ca_county = ws1.ca_county
+    and ws1.d_qoy = 1
+    and ws1.d_year = 2000
+    and ws1.ca_county = ws2.ca_county
+    and ws2.d_qoy = 2
+    and ws2.d_year = 2000
+    and ws1.ca_county = ws3.ca_county
+    and ws3.d_qoy = 3
+    and ws3.d_year =2000
+    and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null 
end 
+       > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales 
else null end
+    and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null 
end
+       > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales 
else null end
+ order by ss1.d_year
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+with ss as
+ (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales
+ from store_sales,date_dim,customer_address
+ where ss_sold_date_sk = d_date_sk
+  and ss_addr_sk=ca_address_sk
+ group by ca_county,d_qoy, d_year),
+ ws as
+ (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales
+ from web_sales,date_dim,customer_address
+ where ws_sold_date_sk = d_date_sk
+  and ws_bill_addr_sk=ca_address_sk
+ group by ca_county,d_qoy, d_year)
+ select /* tt */
+        ss1.ca_county
+       ,ss1.d_year
+       ,ws2.web_sales/ws1.web_sales web_q1_q2_increase
+       ,ss2.store_sales/ss1.store_sales store_q1_q2_increase
+       ,ws3.web_sales/ws2.web_sales web_q2_q3_increase
+       ,ss3.store_sales/ss2.store_sales store_q2_q3_increase
+ from
+        ss ss1
+       ,ss ss2
+       ,ss ss3
+       ,ws ws1
+       ,ws ws2
+       ,ws ws3
+ where
+    ss1.d_qoy = 1
+    and ss1.d_year = 2000
+    and ss1.ca_county = ss2.ca_county
+    and ss2.d_qoy = 2
+    and ss2.d_year = 2000
+ and ss2.ca_county = ss3.ca_county
+    and ss3.d_qoy = 3
+    and ss3.d_year = 2000
+    and ss1.ca_county = ws1.ca_county
+    and ws1.d_qoy = 1
+    and ws1.d_year = 2000
+    and ws1.ca_county = ws2.ca_county
+    and ws2.d_qoy = 2
+    and ws2.d_year = 2000
+    and ws1.ca_county = ws3.ca_county
+    and ws3.d_qoy = 3
+    and ws3.d_year =2000
+    and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null 
end 
+       > case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales 
else null end
+    and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null 
end
+       > case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales 
else null end
+ order by ss1.d_year
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 23 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 14 <- Map 23 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (ONE_TO_ONE_EDGE), Reducer 19 (ONE_TO_ONE_EDGE), 
Reducer 22 (ONE_TO_ONE_EDGE)
+Reducer 17 <- Map 12 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 18 <- Map 23 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 20 <- Map 12 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 21 <- Map 23 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (SIMPLE_EDGE)
+Reducer 3 <- Map 23 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 11 (ONE_TO_ONE_EDGE), Reducer 16 (SIMPLE_EDGE), Reducer 4 
(ONE_TO_ONE_EDGE), Reducer 8 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 7 <- Map 23 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 5
+      File Output Operator [FS_133]
+        Select Operator [SEL_132] (rows=287493839 width=88)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          Filter Operator [FIL_130] (rows=287493839 width=88)
+            predicate:(CASE WHEN ((_col1 > 0)) THEN (CASE WHEN ((_col9 > 0)) 
THEN (((_col11 / _col9) > (_col5 / _col1))) ELSE ((null > (_col5 / _col1))) 
END) ELSE (CASE WHEN ((_col9 > 0)) THEN (((_col11 / _col9) > null)) ELSE (null) 
END) END and CASE WHEN ((_col3 > 0)) THEN (CASE WHEN ((_col7 > 0)) THEN 
(((_col9 / _col7) > (_col1 / _col3))) ELSE ((null > (_col1 / _col3))) END) ELSE 
(CASE WHEN ((_col7 > 0)) THEN (((_col9 / _col7) > null)) ELSE (null) END) END)
+            Merge Join Operator [MERGEJOIN_267] (rows=1149975359 width=88)
+              
Conds:RS_125._col0=RS_126._col0(Inner),RS_125._col0=RS_127._col0(Inner),RS_125._col0=RS_128._col0(Inner),Output:["_col0","_col1","_col3","_col5","_col7","_col9","_col11"]
+            <-Reducer 11 [ONE_TO_ONE_EDGE]
+              FORWARD [RS_127]
+                PartitionCols:_col0
+                Group By Operator [GBY_58] (rows=348477374 width=88)
+                  
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 10 [SIMPLE_EDGE]
+                  SHUFFLE [RS_57]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_56] (rows=696954748 width=88)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                      Merge Join Operator [MERGEJOIN_259] (rows=696954748 
width=88)
+                        
Conds:RS_52._col1=RS_53._col0(Inner),Output:["_col2","_col7"]
+                      <-Map 23 [SIMPLE_EDGE]
+                        SHUFFLE [RS_53]
+                          PartitionCols:_col0
+                          Select Operator [SEL_8] (rows=40000000 width=1014)
+                            Output:["_col0","_col1"]
+                            Filter Operator [FIL_238] (rows=40000000 
width=1014)
+                              predicate:(ca_address_sk is not null and 
ca_county is not null)
+                              TableScan [TS_6] (rows=40000000 width=1014)
+                                
default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_county"]
+                      <-Reducer 9 [SIMPLE_EDGE]
+                        SHUFFLE [RS_52]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_258] (rows=633595212 
width=88)
+                            
Conds:RS_49._col0=RS_50._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 12 [SIMPLE_EDGE]
+                            SHUFFLE [RS_50]
+                              PartitionCols:_col0
+                              Select Operator [SEL_45] (rows=18262 width=1119)
+                                Output:["_col0"]
+                                Filter Operator [FIL_243] (rows=18262 
width=1119)
+                                  predicate:((d_qoy = 3) and (d_year = 2000) 
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_qoy"]
+                          <-Map 1 [SIMPLE_EDGE]
+                            SHUFFLE [RS_49]
+                              PartitionCols:_col0
+                              Select Operator [SEL_2] (rows=575995635 width=88)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_236] (rows=575995635 
width=88)
+                                  predicate:(ss_addr_sk is not null and 
ss_sold_date_sk is not null)
+                                  TableScan [TS_0] (rows=575995635 width=88)
+                                    
default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_addr_sk","ss_ext_sales_price"]
+            <-Reducer 16 [SIMPLE_EDGE]
+              SHUFFLE [RS_128]
+                PartitionCols:_col0
+                Merge Join Operator [MERGEJOIN_266] (rows=191667561 width=135)
+                  
Conds:RS_120._col0=RS_121._col0(Inner),RS_120._col0=RS_122._col0(Inner),Output:["_col0","_col1","_col3","_col5"]
+                <-Reducer 15 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_120]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_78] (rows=87121617 width=135)
+                      
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                    <-Reducer 14 [SIMPLE_EDGE]
+                      SHUFFLE [RS_77]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_76] (rows=174243235 width=135)
+                          
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                          Merge Join Operator [MERGEJOIN_261] (rows=174243235 
width=135)
+                            
Conds:RS_72._col1=RS_73._col0(Inner),Output:["_col2","_col7"]
+                          <-Map 23 [SIMPLE_EDGE]
+                            SHUFFLE [RS_73]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator 
[SEL_8]
+                          <-Reducer 13 [SIMPLE_EDGE]
+                            SHUFFLE [RS_72]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_260] 
(rows=158402938 width=135)
+                                
Conds:RS_69._col0=RS_70._col0(Inner),Output:["_col1","_col2"]
+                              <-Map 12 [SIMPLE_EDGE]
+                                SHUFFLE [RS_70]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_65] (rows=18262 
width=1119)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_246] (rows=18262 
width=1119)
+                                      predicate:((d_qoy = 1) and (d_year = 
2000) and d_date_sk is not null)
+                                       Please refer to the previous TableScan 
[TS_3]
+                              <-Map 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_69]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_62] (rows=144002668 
width=135)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_245] (rows=144002668 
width=135)
+                                      predicate:(ws_bill_addr_sk is not null 
and ws_sold_date_sk is not null)
+                                      TableScan [TS_60] (rows=144002668 
width=135)
+                                        
default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                <-Reducer 19 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_121]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_98] (rows=87121617 width=135)
+                      
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                    <-Reducer 18 [SIMPLE_EDGE]
+                      SHUFFLE [RS_97]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_96] (rows=174243235 width=135)
+                          
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                          Merge Join Operator [MERGEJOIN_263] (rows=174243235 
width=135)
+                            
Conds:RS_92._col1=RS_93._col0(Inner),Output:["_col2","_col7"]
+                          <-Map 23 [SIMPLE_EDGE]
+                            SHUFFLE [RS_93]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator 
[SEL_8]
+                          <-Reducer 17 [SIMPLE_EDGE]
+                            SHUFFLE [RS_92]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_262] 
(rows=158402938 width=135)
+                                
Conds:RS_89._col0=RS_90._col0(Inner),Output:["_col1","_col2"]
+                              <-Map 12 [SIMPLE_EDGE]
+                                SHUFFLE [RS_90]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_85] (rows=18262 
width=1119)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_249] (rows=18262 
width=1119)
+                                      predicate:((d_qoy = 2) and (d_year = 
2000) and d_date_sk is not null)
+                                       Please refer to the previous TableScan 
[TS_3]
+                              <-Map 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_89]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select 
Operator [SEL_62]
+                <-Reducer 22 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_122]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_118] (rows=87121617 width=135)
+                      
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                    <-Reducer 21 [SIMPLE_EDGE]
+                      SHUFFLE [RS_117]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_116] (rows=174243235 width=135)
+                          
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                          Merge Join Operator [MERGEJOIN_265] (rows=174243235 
width=135)
+                            
Conds:RS_112._col1=RS_113._col0(Inner),Output:["_col2","_col7"]
+                          <-Map 23 [SIMPLE_EDGE]
+                            SHUFFLE [RS_113]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator 
[SEL_8]
+                          <-Reducer 20 [SIMPLE_EDGE]
+                            SHUFFLE [RS_112]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_264] 
(rows=158402938 width=135)
+                                
Conds:RS_109._col0=RS_110._col0(Inner),Output:["_col1","_col2"]
+                              <-Map 12 [SIMPLE_EDGE]
+                                SHUFFLE [RS_110]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_105] (rows=18262 
width=1119)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_252] (rows=18262 
width=1119)
+                                      predicate:((d_qoy = 3) and (d_year = 
2000) and d_date_sk is not null)
+                                       Please refer to the previous TableScan 
[TS_3]
+                              <-Map 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_109]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select 
Operator [SEL_62]
+            <-Reducer 4 [ONE_TO_ONE_EDGE]
+              FORWARD [RS_125]
+                PartitionCols:_col0
+                Group By Operator [GBY_18] (rows=348477374 width=88)
+                  
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 3 [SIMPLE_EDGE]
+                  SHUFFLE [RS_17]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_16] (rows=696954748 width=88)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                      Merge Join Operator [MERGEJOIN_255] (rows=696954748 
width=88)
+                        
Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7"]
+                      <-Map 23 [SIMPLE_EDGE]
+                        SHUFFLE [RS_13]
+                          PartitionCols:_col0
+                           Please refer to the previous Select Operator [SEL_8]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_12]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_254] (rows=633595212 
width=88)
+                            
Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 12 [SIMPLE_EDGE]
+                            SHUFFLE [RS_10]
+                              PartitionCols:_col0
+                              Select Operator [SEL_5] (rows=18262 width=1119)
+                                Output:["_col0"]
+                                Filter Operator [FIL_237] (rows=18262 
width=1119)
+                                  predicate:((d_qoy = 2) and (d_year = 2000) 
and d_date_sk is not null)
+                                   Please refer to the previous TableScan 
[TS_3]
+                          <-Map 1 [SIMPLE_EDGE]
+                            SHUFFLE [RS_9]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator 
[SEL_2]
+            <-Reducer 8 [ONE_TO_ONE_EDGE]
+              FORWARD [RS_126]
+                PartitionCols:_col0
+                Group By Operator [GBY_38] (rows=348477374 width=88)
+                  
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 7 [SIMPLE_EDGE]
+                  SHUFFLE [RS_37]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_36] (rows=696954748 width=88)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
+                      Merge Join Operator [MERGEJOIN_257] (rows=696954748 
width=88)
+                        
Conds:RS_32._col1=RS_33._col0(Inner),Output:["_col2","_col7"]
+                      <-Map 23 [SIMPLE_EDGE]
+                        SHUFFLE [RS_33]
+                          PartitionCols:_col0
+                           Please refer to the previous Select Operator [SEL_8]
+                      <-Reducer 6 [SIMPLE_EDGE]
+                        SHUFFLE [RS_32]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_256] (rows=633595212 
width=88)
+                            
Conds:RS_29._col0=RS_30._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 12 [SIMPLE_EDGE]
+                            SHUFFLE [RS_30]
+                              PartitionCols:_col0
+                              Select Operator [SEL_25] (rows=18262 width=1119)
+                                Output:["_col0"]
+                                Filter Operator [FIL_240] (rows=18262 
width=1119)
+                                  predicate:((d_qoy = 1) and (d_year = 2000) 
and d_date_sk is not null)
+                                   Please refer to the previous TableScan 
[TS_3]
+                          <-Map 1 [SIMPLE_EDGE]
+                            SHUFFLE [RS_29]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator 
[SEL_2]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query32.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query32.q.out
new file mode 100644
index 0000000..7b21854
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query32.q.out
@@ -0,0 +1,144 @@
+PREHOOK: query: explain
+select  sum(cs_ext_discount_amt)  as `excess discount amount` 
+from 
+   catalog_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = cs_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = cs_sold_date_sk 
+and cs_ext_discount_amt  
+     > ( 
+         select 
+            1.3 * avg(cs_ext_discount_amt) 
+         from 
+            catalog_sales 
+           ,date_dim
+         where 
+              cs_item_sk = i_item_sk 
+          and d_date between '1998-03-18' and
+                             (cast('1998-03-18' as date) + 90 days)
+          and d_date_sk = cs_sold_date_sk 
+      ) 
+limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select  sum(cs_ext_discount_amt)  as `excess discount amount` 
+from 
+   catalog_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = cs_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = cs_sold_date_sk 
+and cs_ext_discount_amt  
+     > ( 
+         select 
+            1.3 * avg(cs_ext_discount_amt) 
+         from 
+            catalog_sales 
+           ,date_dim
+         where 
+              cs_item_sk = i_item_sk 
+          and d_date between '1998-03-18' and
+                             (cast('1998-03-18' as date) + 90 days)
+          and d_date_sk = cs_sold_date_sk 
+      ) 
+limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 9 (SIMPLE_EDGE), Reducer 6 (ONE_TO_ONE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4
+      File Output Operator [FS_40]
+        Limit [LIM_39] (rows=1 width=112)
+          Number of rows:100
+          Group By Operator [GBY_37] (rows=1 width=112)
+            Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+          <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+            PARTITION_ONLY_SHUFFLE [RS_36]
+              Group By Operator [GBY_35] (rows=1 width=112)
+                Output:["_col0"],aggregations:["sum(_col2)"]
+                Select Operator [SEL_34] (rows=116155905 width=135)
+                  Output:["_col2"]
+                  Filter Operator [FIL_33] (rows=116155905 width=135)
+                    predicate:(_col2 > _col5)
+                    Merge Join Operator [MERGEJOIN_61] (rows=348467716 
width=135)
+                      
Conds:RS_30._col1=RS_31._col2(Inner),Output:["_col2","_col5"]
+                    <-Reducer 2 [SIMPLE_EDGE]
+                      SHUFFLE [RS_30]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_58] (rows=316788826 
width=135)
+                          
Conds:RS_27._col0=RS_28._col0(Inner),Output:["_col1","_col2"]
+                        <-Map 1 [SIMPLE_EDGE]
+                          SHUFFLE [RS_27]
+                            PartitionCols:_col0
+                            Select Operator [SEL_2] (rows=287989836 width=135)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_53] (rows=287989836 
width=135)
+                                predicate:(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_item_sk","cs_ext_discount_amt"]
+                        <-Map 8 [SIMPLE_EDGE]
+                          SHUFFLE [RS_28]
+                            PartitionCols:_col0
+                            Select Operator [SEL_5] (rows=8116 width=1119)
+                              Output:["_col0"]
+                              Filter Operator [FIL_54] (rows=8116 width=1119)
+                                predicate:(CAST( d_date AS TIMESTAMP) BETWEEN 
1998-03-18 00:00:00.0 AND 1998-06-16 01:00:00.0 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_date"]
+                    <-Reducer 7 [SIMPLE_EDGE]
+                      SHUFFLE [RS_31]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_60] (rows=174233858 
width=135)
+                          
Conds:RS_23._col1=RS_24._col0(Inner),Output:["_col0","_col2"]
+                        <-Map 9 [SIMPLE_EDGE]
+                          SHUFFLE [RS_24]
+                            PartitionCols:_col0
+                            Select Operator [SEL_22] (rows=231000 width=1436)
+                              Output:["_col0"]
+                              Filter Operator [FIL_57] (rows=231000 width=1436)
+                                predicate:((i_manufact_id = 269) and i_item_sk 
is not null)
+                                TableScan [TS_20] (rows=462000 width=1436)
+                                  
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_manufact_id"]
+                        <-Reducer 6 [ONE_TO_ONE_EDGE]
+                          FORWARD [RS_23]
+                            PartitionCols:_col1
+                            Select Operator [SEL_19] (rows=158394413 width=135)
+                              Output:["_col0","_col1"]
+                              Group By Operator [GBY_18] (rows=158394413 
width=135)
+                                
Output:["_col0","_col1"],aggregations:["avg(VALUE._col0)"],keys:KEY._col0
+                              <-Reducer 5 [SIMPLE_EDGE]
+                                SHUFFLE [RS_17]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_16] (rows=316788826 
width=135)
+                                    
Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col1
+                                    Merge Join Operator [MERGEJOIN_59] 
(rows=316788826 width=135)
+                                      
Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 1 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_12]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select 
Operator [SEL_2]
+                                    <-Map 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_13]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select 
Operator [SEL_5]
+

Reply via email to