http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query54.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query54.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query54.q.out
new file mode 100644
index 0000000..e6b9b28
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query54.q.out
@@ -0,0 +1,386 @@
+Warning: Shuffle Join MERGEJOIN[184][tables = [$hdt$_0, $hdt$_1, $hdt$_2, 
$hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[185][tables = [$hdt$_0, $hdt$_1, $hdt$_2, 
$hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[183][tables = [$hdt$_1, $hdt$_2]] in Stage 
'Reducer 30' is a cross product
+Warning: Shuffle Join MERGEJOIN[186][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in 
Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy 
= 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy 
= 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy 
= 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy 
= 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 15 <- Union 16 (CONTAINS)
+Map 21 <- Union 16 (CONTAINS)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 17 <- Map 22 (SIMPLE_EDGE), Union 16 (SIMPLE_EDGE)
+Reducer 18 <- Map 23 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Map 24 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (SIMPLE_EDGE)
+Reducer 26 <- Map 25 (SIMPLE_EDGE)
+Reducer 27 <- Reducer 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 25 (SIMPLE_EDGE)
+Reducer 29 <- Map 25 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Reducer 29 (CUSTOM_SIMPLE_EDGE), Reducer 32 (CUSTOM_SIMPLE_EDGE)
+Reducer 31 <- Map 25 (SIMPLE_EDGE)
+Reducer 32 <- Reducer 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 27 (CUSTOM_SIMPLE_EDGE), Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 28 (CUSTOM_SIMPLE_EDGE), Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 30 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 9
+      File Output Operator [FS_130]
+        Limit [LIM_129] (rows=100 width=158)
+          Number of rows:100
+          Select Operator [SEL_128] (rows=1614130953450400 width=158)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 8 [SIMPLE_EDGE]
+            SHUFFLE [RS_127]
+              Select Operator [SEL_126] (rows=1614130953450400 width=158)
+                Output:["_col0","_col1","_col2"]
+                Group By Operator [GBY_125] (rows=1614130953450400 width=158)
+                  
Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 7 [SIMPLE_EDGE]
+                  SHUFFLE [RS_124]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_123] (rows=3228261906900801 
width=158)
+                      
Output:["_col0","_col1"],aggregations:["count()"],keys:_col0
+                      Select Operator [SEL_121] (rows=3228261906900801 
width=158)
+                        Output:["_col0"]
+                        Group By Operator [GBY_120] (rows=3228261906900801 
width=158)
+                          
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 6 [SIMPLE_EDGE]
+                          SHUFFLE [RS_119]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_118] (rows=6456523813801603 
width=158)
+                              
Output:["_col0","_col1"],aggregations:["sum(_col4)"],keys:_col0
+                              Select Operator [SEL_117] (rows=6456523813801603 
width=158)
+                                Output:["_col0","_col4"]
+                                Filter Operator [FIL_116] 
(rows=6456523813801603 width=158)
+                                  predicate:_col11 BETWEEN _col13 AND _col15
+                                  Select Operator [SEL_115] 
(rows=58108714324214428 width=158)
+                                    
Output:["_col0","_col4","_col11","_col13","_col15"]
+                                    Merge Join Operator [MERGEJOIN_186] 
(rows=58108714324214428 width=158)
+                                      
Conds:(Inner),Output:["_col0","_col2","_col6","_col13","_col15"]
+                                    <-Reducer 30 [CUSTOM_SIMPLE_EDGE]
+                                      PARTITION_ONLY_SHUFFLE [RS_112]
+                                        Merge Join Operator [MERGEJOIN_183] 
(rows=9131 width=1128)
+                                          Conds:(Right Outer),Output:["_col0"]
+                                        <-Reducer 29 [CUSTOM_SIMPLE_EDGE]
+                                          PARTITION_ONLY_SHUFFLE [RS_109]
+                                            Group By Operator [GBY_6] 
(rows=9131 width=1119)
+                                              Output:["_col0"],keys:KEY._col0
+                                            <-Map 25 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_5]
+                                                PartitionCols:_col0
+                                                Group By Operator [GBY_4] 
(rows=18262 width=1119)
+                                                  Output:["_col0"],keys:_col0
+                                                  Select Operator [SEL_2] 
(rows=18262 width=1119)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_174] 
(rows=18262 width=1119)
+                                                      predicate:((d_moy = 3) 
and (d_year = 1999))
+                                                      TableScan [TS_73] 
(rows=73049 width=1119)
+                                                        
default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_month_seq","d_year","d_moy"]
+                                        <-Reducer 32 [CUSTOM_SIMPLE_EDGE]
+                                          PARTITION_ONLY_SHUFFLE [RS_110]
+                                            Select Operator [SEL_22] (rows=1 
width=8)
+                                              Filter Operator [FIL_21] (rows=1 
width=8)
+                                                
predicate:(sq_count_check(_col0) <= 1)
+                                                Group By Operator [GBY_19] 
(rows=1 width=8)
+                                                  
Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                <-Reducer 31 
[CUSTOM_SIMPLE_EDGE]
+                                                  PARTITION_ONLY_SHUFFLE 
[RS_18]
+                                                    Group By Operator [GBY_17] 
(rows=1 width=8)
+                                                      
Output:["_col0"],aggregations:["count()"]
+                                                      Select Operator [SEL_15] 
(rows=9131 width=1119)
+                                                        Group By Operator 
[GBY_14] (rows=9131 width=1119)
+                                                          
Output:["_col0"],keys:KEY._col0
+                                                        <-Map 25 [SIMPLE_EDGE]
+                                                          SHUFFLE [RS_13]
+                                                            PartitionCols:_col0
+                                                            Group By Operator 
[GBY_12] (rows=18262 width=1119)
+                                                              
Output:["_col0"],keys:_col0
+                                                              Select Operator 
[SEL_10] (rows=18262 width=1119)
+                                                                
Output:["_col0"]
+                                                                 Please refer 
to the previous Filter Operator [FIL_174]
+                                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                      PARTITION_ONLY_SHUFFLE [RS_113]
+                                        Select Operator [SEL_108] 
(rows=6363893803988 width=1217)
+                                          
Output:["_col0","_col4","_col11","_col13"]
+                                          Merge Join Operator [MERGEJOIN_185] 
(rows=6363893803988 width=1217)
+                                            Conds:(Left 
Outer),Output:["_col2","_col4","_col10","_col13"]
+                                          <-Reducer 28 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_106]
+                                              Group By Operator [GBY_94] 
(rows=9131 width=1119)
+                                                Output:["_col0"],keys:KEY._col0
+                                              <-Map 25 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_93]
+                                                  PartitionCols:_col0
+                                                  Group By Operator [GBY_77] 
(rows=18262 width=1119)
+                                                    Output:["_col0"],keys:_col0
+                                                    Select Operator [SEL_75] 
(rows=18262 width=1119)
+                                                      Output:["_col0"]
+                                                       Please refer to the 
previous Filter Operator [FIL_174]
+                                          <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_105]
+                                              Merge Join Operator 
[MERGEJOIN_184] (rows=696954748 width=97)
+                                                
Conds:(Inner),Output:["_col2","_col4","_col10"]
+                                              <-Reducer 27 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_103]
+                                                  Select Operator [SEL_87] 
(rows=1 width=8)
+                                                    Filter Operator [FIL_86] 
(rows=1 width=8)
+                                                      
predicate:(sq_count_check(_col0) <= 1)
+                                                      Group By Operator 
[GBY_84] (rows=1 width=8)
+                                                        
Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                      <-Reducer 26 
[CUSTOM_SIMPLE_EDGE]
+                                                        PARTITION_ONLY_SHUFFLE 
[RS_83]
+                                                          Group By Operator 
[GBY_82] (rows=1 width=8)
+                                                            
Output:["_col0"],aggregations:["count()"]
+                                                            Select Operator 
[SEL_80] (rows=9131 width=1119)
+                                                              Group By 
Operator [GBY_79] (rows=9131 width=1119)
+                                                                
Output:["_col0"],keys:KEY._col0
+                                                              <-Map 25 
[SIMPLE_EDGE]
+                                                                SHUFFLE [RS_78]
+                                                                  
PartitionCols:_col0
+                                                                   Please 
refer to the previous Group By Operator [GBY_77]
+                                              <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_102]
+                                                  Merge Join Operator 
[MERGEJOIN_182] (rows=696954748 width=88)
+                                                    
Conds:RS_99._col1=RS_100._col5(Inner),Output:["_col2","_col4","_col10"]
+                                                  <-Reducer 13 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_100]
+                                                      PartitionCols:_col5
+                                                      Merge Join Operator 
[MERGEJOIN_181] (rows=316240138 width=135)
+                                                        
Conds:RS_69._col0=RS_70._col1(Inner),Output:["_col5"]
+                                                      <-Reducer 12 
[SIMPLE_EDGE]
+                                                        SHUFFLE [RS_69]
+                                                          PartitionCols:_col0
+                                                          Merge Join Operator 
[MERGEJOIN_177] (rows=44000000 width=1014)
+                                                            Conds:RS_66._col1, 
_col2=RS_67._col0, _col1(Inner),Output:["_col0"]
+                                                          <-Map 11 
[SIMPLE_EDGE]
+                                                            SHUFFLE [RS_66]
+                                                              
PartitionCols:_col1, _col2
+                                                              Select Operator 
[SEL_31] (rows=40000000 width=1014)
+                                                                
Output:["_col0","_col1","_col2"]
+                                                                Filter 
Operator [FIL_167] (rows=40000000 width=1014)
+                                                                  
predicate:(ca_address_sk is not null and ca_county is not null and ca_state is 
not null)
+                                                                  TableScan 
[TS_29] (rows=40000000 width=1014)
+                                                                    
default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_county","ca_state"]
+                                                          <-Map 14 
[SIMPLE_EDGE]
+                                                            SHUFFLE [RS_67]
+                                                              
PartitionCols:_col0, _col1
+                                                              Select Operator 
[SEL_34] (rows=1704 width=1910)
+                                                                
Output:["_col0","_col1"]
+                                                                Filter 
Operator [FIL_168] (rows=1704 width=1910)
+                                                                  
predicate:(s_county is not null and s_state is not null)
+                                                                  TableScan 
[TS_32] (rows=1704 width=1910)
+                                                                    
default@store,store,Tbl:COMPLETE,Col:NONE,Output:["s_county","s_state"]
+                                                      <-Reducer 20 
[SIMPLE_EDGE]
+                                                        SHUFFLE [RS_70]
+                                                          PartitionCols:_col1
+                                                          Select Operator 
[SEL_65] (rows=287491029 width=135)
+                                                            
Output:["_col0","_col1"]
+                                                            Group By Operator 
[GBY_64] (rows=287491029 width=135)
+                                                              
Output:["_col0","_col1"],keys:KEY._col0, KEY._col1
+                                                            <-Reducer 19 
[SIMPLE_EDGE]
+                                                              SHUFFLE [RS_63]
+                                                                
PartitionCols:_col0, _col1
+                                                                Group By 
Operator [GBY_62] (rows=574982058 width=135)
+                                                                  
Output:["_col0","_col1"],keys:_col10, _col9
+                                                                  Merge Join 
Operator [MERGEJOIN_180] (rows=574982058 width=135)
+                                                                    
Conds:RS_58._col1=RS_59._col0(Inner),Output:["_col9","_col10"]
+                                                                  <-Map 24 
[SIMPLE_EDGE]
+                                                                    SHUFFLE 
[RS_59]
+                                                                      
PartitionCols:_col0
+                                                                      Select 
Operator [SEL_51] (rows=80000000 width=860)
+                                                                        
Output:["_col0","_col1"]
+                                                                        Filter 
Operator [FIL_173] (rows=80000000 width=860)
+                                                                          
predicate:(c_current_addr_sk is not null and c_customer_sk is not null)
+                                                                          
TableScan [TS_49] (rows=80000000 width=860)
+                                                                            
default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_current_addr_sk"]
+                                                                  <-Reducer 18 
[SIMPLE_EDGE]
+                                                                    SHUFFLE 
[RS_58]
+                                                                      
PartitionCols:_col1
+                                                                      Merge 
Join Operator [MERGEJOIN_179] (rows=522710951 width=135)
+                                                                        
Conds:RS_55._col2=RS_56._col0(Inner),Output:["_col1"]
+                                                                      <-Map 23 
[SIMPLE_EDGE]
+                                                                        
SHUFFLE [RS_56]
+                                                                          
PartitionCols:_col0
+                                                                          
Select Operator [SEL_48] (rows=115500 width=1436)
+                                                                            
Output:["_col0"]
+                                                                            
Filter Operator [FIL_172] (rows=115500 width=1436)
+                                                                              
predicate:((i_category = 'Jewelry') and (i_class = 'consignment') and i_item_sk 
is not null)
+                                                                              
TableScan [TS_46] (rows=462000 width=1436)
+                                                                               
 
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_class","i_category"]
+                                                                      
<-Reducer 17 [SIMPLE_EDGE]
+                                                                        
SHUFFLE [RS_55]
+                                                                          
PartitionCols:_col2
+                                                                          
Merge Join Operator [MERGEJOIN_178] (rows=475191764 width=135)
+                                                                            
Conds:Union 16._col0=RS_53._col0(Inner),Output:["_col1","_col2"]
+                                                                          
<-Map 22 [SIMPLE_EDGE]
+                                                                            
SHUFFLE [RS_53]
+                                                                              
PartitionCols:_col0
+                                                                              
Select Operator [SEL_45] (rows=18262 width=1119)
+                                                                               
 Output:["_col0"]
+                                                                               
 Filter Operator [FIL_171] (rows=18262 width=1119)
+                                                                               
   predicate:((d_moy = 3) and (d_year = 1999) and d_date_sk is not null)
+                                                                               
   TableScan [TS_43] (rows=73049 width=1119)
+                                                                               
     
default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                                                          
<-Union 16 [SIMPLE_EDGE]
+                                                                            
<-Map 15 [CONTAINS]
+                                                                              
Reduce Output Operator [RS_52]
+                                                                               
 PartitionCols:_col0
+                                                                               
 Select Operator [SEL_37] (rows=287989836 width=135)
+                                                                               
   Output:["_col0","_col1","_col2"]
+                                                                               
   Filter Operator [FIL_169] (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_35] (rows=287989836 width=135)
+                                                                               
       Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk"]
+                                                                            
<-Map 21 [CONTAINS]
+                                                                              
Reduce Output Operator [RS_52]
+                                                                               
 PartitionCols:_col0
+                                                                               
 Select Operator [SEL_40] (rows=144002668 width=135)
+                                                                               
   Output:["_col0","_col1","_col2"]
+                                                                               
   Filter Operator [FIL_170] (rows=144002668 width=135)
+                                                                               
     predicate:(ws_bill_customer_sk is not null and ws_item_sk is not null and 
ws_sold_date_sk is not null)
+                                                                               
     TableScan [TS_38] (rows=144002668 width=135)
+                                                                               
       Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk"]
+                                                  <-Reducer 2 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_99]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator 
[MERGEJOIN_176] (rows=633595212 width=88)
+                                                        
Conds:RS_96._col0=RS_97._col0(Inner),Output:["_col1","_col2","_col4"]
+                                                      <-Map 1 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_96]
+                                                          PartitionCols:_col0
+                                                          Select Operator 
[SEL_25] (rows=575995635 width=88)
+                                                            
Output:["_col0","_col1","_col2"]
+                                                            Filter Operator 
[FIL_165] (rows=575995635 width=88)
+                                                              
predicate:(ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                              TableScan 
[TS_23] (rows=575995635 width=88)
+                                                                
default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_sales_price"]
+                                                      <-Map 10 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_97]
+                                                          PartitionCols:_col0
+                                                          Select Operator 
[SEL_28] (rows=73049 width=1119)
+                                                            
Output:["_col0","_col1"]
+                                                            Filter Operator 
[FIL_166] (rows=73049 width=1119)
+                                                              
predicate:d_date_sk is not null
+                                                              TableScan 
[TS_26] (rows=73049 width=1119)
+                                                                
default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_month_seq"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query55.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query55.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query55.q.out
new file mode 100644
index 0000000..27ea1c3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query55.q.out
@@ -0,0 +1,88 @@
+PREHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand,
+       sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+       and ss_item_sk = i_item_sk
+       and i_manager_id=36
+       and d_moy=12
+       and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand,
+       sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+       and ss_item_sk = i_item_sk
+       and i_manager_id=36
+       and d_moy=12
+       and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_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"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_21]
+              Group By Operator [GBY_18] (rows=348477374 width=88)
+                
Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_17]
+                  PartitionCols:_col0, _col1
+                  Group By Operator [GBY_16] (rows=696954748 width=88)
+                    
Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col7, _col8
+                    Merge Join Operator [MERGEJOIN_34] (rows=696954748 
width=88)
+                      
Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7","_col8"]
+                    <-Map 7 [SIMPLE_EDGE]
+                      SHUFFLE [RS_13]
+                        PartitionCols:_col0
+                        Select Operator [SEL_8] (rows=231000 width=1436)
+                          Output:["_col0","_col1","_col2"]
+                          Filter Operator [FIL_32] (rows=231000 width=1436)
+                            predicate:((i_manager_id = 36) and i_item_sk is 
not null)
+                            TableScan [TS_6] (rows=462000 width=1436)
+                              
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand_id","i_brand","i_manager_id"]
+                    <-Reducer 2 [SIMPLE_EDGE]
+                      SHUFFLE [RS_12]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_33] (rows=633595212 
width=88)
+                          
Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
+                        <-Map 1 [SIMPLE_EDGE]
+                          SHUFFLE [RS_9]
+                            PartitionCols:_col0
+                            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=18262 width=1119)
+                              Output:["_col0"]
+                              Filter Operator [FIL_31] (rows=18262 width=1119)
+                                predicate:((d_moy = 12) and (d_year = 2001) 
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_moy"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query56.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query56.q.out
new file mode 100644
index 0000000..4041740
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query56.q.out
@@ -0,0 +1,379 @@
+PREHOOK: query: explain
+with ss as (
+ select i_item_id,sum(ss_ext_sales_price) total_sales
+ from
+       store_sales,
+       date_dim,
+         customer_address,
+         item
+ where i_item_id in (select
+     i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -8 
+ group by i_item_id),
+ cs as (
+ select i_item_id,sum(cs_ext_sales_price) total_sales
+ from
+       catalog_sales,
+       date_dim,
+         customer_address,
+         item
+ where
+         i_item_id               in (select
+  i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -8 
+ group by i_item_id),
+ ws as (
+ select i_item_id,sum(ws_ext_sales_price) total_sales
+ from
+       web_sales,
+       date_dim,
+         customer_address,
+         item
+ where
+         i_item_id               in (select
+  i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -8
+ group by i_item_id)
+  select  i_item_id ,sum(total_sales) total_sales
+ from  (select * from ss 
+        union all
+        select * from cs 
+        union all
+        select * from ws) tmp1
+ group by i_item_id
+ order by total_sales
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+with ss as (
+ select i_item_id,sum(ss_ext_sales_price) total_sales
+ from
+       store_sales,
+       date_dim,
+         customer_address,
+         item
+ where i_item_id in (select
+     i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -8 
+ group by i_item_id),
+ cs as (
+ select i_item_id,sum(cs_ext_sales_price) total_sales
+ from
+       catalog_sales,
+       date_dim,
+         customer_address,
+         item
+ where
+         i_item_id               in (select
+  i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -8 
+ group by i_item_id),
+ ws as (
+ select i_item_id,sum(ws_ext_sales_price) total_sales
+ from
+       web_sales,
+       date_dim,
+         customer_address,
+         item
+ where
+         i_item_id               in (select
+  i_item_id
+from item
+where i_color in ('orchid','chiffon','lace'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 2000
+ and     d_moy                   = 1
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -8
+ group by i_item_id)
+  select  i_item_id ,sum(total_sales) total_sales
+ from  (select * from ss 
+        union all
+        select * from cs 
+        union all
+        select * from ws) tmp1
+ group by i_item_id
+ order by total_sales
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 11 <- Map 1 (SIMPLE_EDGE), Reducer 17 (ONE_TO_ONE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 15 <- Map 14 (SIMPLE_EDGE)
+Reducer 16 <- Map 14 (SIMPLE_EDGE)
+Reducer 17 <- Map 14 (SIMPLE_EDGE)
+Reducer 19 <- Map 18 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 15 (ONE_TO_ONE_EDGE)
+Reducer 20 <- Map 26 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (SIMPLE_EDGE), Map 27 (SIMPLE_EDGE)
+Reducer 23 <- Map 26 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Map 21 (SIMPLE_EDGE), Map 28 (SIMPLE_EDGE)
+Reducer 25 <- Map 26 (SIMPLE_EDGE), Reducer 24 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 1 (SIMPLE_EDGE), Reducer 16 (ONE_TO_ONE_EDGE)
+Reducer 9 <- Reducer 23 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7
+      File Output Operator [FS_121]
+        Limit [LIM_120] (rows=100 width=108)
+          Number of rows:100
+          Select Operator [SEL_119] (rows=335408073 width=108)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_118]
+              Group By Operator [GBY_116] (rows=335408073 width=108)
+                
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 10 [CONTAINS]
+                  Reduce Output Operator [RS_115]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_114] (rows=670816147 width=108)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_72] (rows=191657247 width=135)
+                        
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 9 [SIMPLE_EDGE]
+                        SHUFFLE [RS_71]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_70] (rows=383314495 width=135)
+                            
Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_183] 
(rows=383314495 width=135)
+                              
Conds:RS_66._col0=RS_67._col4(Inner),Output:["_col1","_col8"]
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_67]
+                                PartitionCols:_col4
+                                Select Operator [SEL_62] (rows=348467716 
width=135)
+                                  Output:["_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_178] 
(rows=348467716 width=135)
+                                    
Conds:RS_59._col1=RS_60._col0(Inner),Output:["_col2","_col3"]
+                                  <-Map 26 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_60]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_18] (rows=20000000 
width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_162] 
(rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -8) and 
ca_address_sk is not null)
+                                          TableScan [TS_16] (rows=40000000 
width=1014)
+                                            
default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_gmt_offset"]
+                                  <-Reducer 22 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_59]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_177] 
(rows=316788826 width=135)
+                                        
Conds:RS_56._col0=RS_57._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_57]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_15] (rows=18262 
width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_161] 
(rows=18262 width=1119)
+                                              predicate:((d_moy = 1) and 
(d_year = 2000) and d_date_sk is not null)
+                                              TableScan [TS_13] (rows=73049 
width=1119)
+                                                
default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 27 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_56]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_49] 
(rows=287989836 width=135)
+                                            
Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_165] 
(rows=287989836 width=135)
+                                              predicate:(cs_bill_addr_sk is 
not null and cs_item_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_47] 
(rows=287989836 width=135)
+                                                
default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
+                            <-Reducer 8 [SIMPLE_EDGE]
+                              SHUFFLE [RS_66]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_176] 
(rows=508200 width=1436)
+                                  
Conds:RS_63._col1=RS_64._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_63]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_2] (rows=462000 
width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_158] (rows=462000 
width=1436)
+                                        predicate:(i_item_id is not null and 
i_item_sk is not null)
+                                        TableScan [TS_0] (rows=462000 
width=1436)
+                                          
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id"]
+                                <-Reducer 16 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_64]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_45] (rows=115500 
width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_44]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_6] (rows=231000 
width=1436)
+                                          Output:["_col0"],keys:i_item_id
+                                          Select Operator [SEL_5] (rows=231000 
width=1436)
+                                            Output:["i_item_id"]
+                                            Filter Operator [FIL_159] 
(rows=231000 width=1436)
+                                              predicate:((i_color) IN 
('orchid', 'chiffon', 'lace') and i_item_id is not null)
+                                              TableScan [TS_3] (rows=462000 
width=1436)
+                                                
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_id","i_color"]
+                <-Reducer 13 [CONTAINS]
+                  Reduce Output Operator [RS_115]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_114] (rows=670816147 width=108)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_110] (rows=95833781 width=135)
+                        
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 12 [SIMPLE_EDGE]
+                        SHUFFLE [RS_109]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_108] (rows=191667562 
width=135)
+                            
Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_184] 
(rows=191667562 width=135)
+                              
Conds:RS_104._col0=RS_105._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 11 [SIMPLE_EDGE]
+                              SHUFFLE [RS_104]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_179] 
(rows=508200 width=1436)
+                                  
Conds:RS_101._col1=RS_102._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_101]
+                                    PartitionCols:_col1
+                                     Please refer to the previous Select 
Operator [SEL_2]
+                                <-Reducer 17 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_102]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_83] (rows=115500 
width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_82]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Group By 
Operator [GBY_6]
+                            <-Reducer 25 [SIMPLE_EDGE]
+                              SHUFFLE [RS_105]
+                                PartitionCols:_col3
+                                Select Operator [SEL_100] (rows=174243235 
width=135)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_181] 
(rows=174243235 width=135)
+                                    
Conds:RS_97._col2=RS_98._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 26 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_98]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select 
Operator [SEL_18]
+                                  <-Reducer 24 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_97]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_180] 
(rows=158402938 width=135)
+                                        
Conds:RS_94._col0=RS_95._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_95]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select 
Operator [SEL_15]
+                                      <-Map 28 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_94]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_87] 
(rows=144002668 width=135)
+                                            
Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_170] 
(rows=144002668 width=135)
+                                              predicate:(ws_bill_addr_sk is 
not null and ws_item_sk is not null and ws_sold_date_sk is not null)
+                                              TableScan [TS_85] 
(rows=144002668 width=135)
+                                                
default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                <-Reducer 4 [CONTAINS]
+                  Reduce Output Operator [RS_115]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_114] (rows=670816147 width=108)
+                      
Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_35] (rows=383325119 width=88)
+                        
Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_34]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_33] (rows=766650239 width=88)
+                            
Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_182] 
(rows=766650239 width=88)
+                              
Conds:RS_29._col0=RS_30._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_173] 
(rows=508200 width=1436)
+                                  
Conds:RS_26._col1=RS_27._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_26]
+                                    PartitionCols:_col1
+                                     Please refer to the previous Select 
Operator [SEL_2]
+                                <-Reducer 15 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_27]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_8] (rows=115500 
width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_7]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Group By 
Operator [GBY_6]
+                            <-Reducer 20 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col3
+                                Select Operator [SEL_25] (rows=696954748 
width=88)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_175] 
(rows=696954748 width=88)
+                                    
Conds:RS_22._col2=RS_23._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 26 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_23]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select 
Operator [SEL_18]
+                                  <-Reducer 19 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_22]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_174] 
(rows=633595212 width=88)
+                                        
Conds:RS_19._col0=RS_20._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_20]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select 
Operator [SEL_15]
+                                      <-Map 18 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_12] 
(rows=575995635 width=88)
+                                            
Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_160] 
(rows=575995635 width=88)
+                                              predicate:(ss_addr_sk is not 
null and ss_item_sk is not null and ss_sold_date_sk is not null)
+                                              TableScan [TS_10] 
(rows=575995635 width=88)
+                                                
default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/9244fdc7/ql/src/test/results/clientpositive/perf/tez/query57.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query57.q.out 
b/ql/src/test/results/clientpositive/perf/tez/query57.q.out
new file mode 100644
index 0000000..1a1bbf1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/query57.q.out
@@ -0,0 +1,319 @@
+PREHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - 
avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - 
avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 21 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 22 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Map 1 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+Reducer 15 <- Map 21 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Map 22 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+Reducer 3 <- Map 21 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 22 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 13 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE), Reducer 6 
(SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Map 1 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 8
+      File Output Operator [FS_112]
+        Limit [LIM_110] (rows=100 width=135)
+          Number of rows:100
+          Select Operator [SEL_109] (rows=421645952 width=135)
+            
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 7 [SIMPLE_EDGE]
+            SHUFFLE [RS_108]
+              Select Operator [SEL_107] (rows=421645952 width=135)
+                
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                Merge Join Operator [MERGEJOIN_189] (rows=421645952 width=135)
+                  Conds:RS_103._col0, _col2, _col1, (_col6 + 1)=RS_104._col0, 
_col2, _col1, _col7(Inner),RS_104._col0, _col2, _col1, _col7=RS_105._col0, 
_col2, _col1, (_col6 - 
1)(Inner),Output:["_col5","_col7","_col8","_col10","_col11","_col12","_col13","_col20"]
+                <-Reducer 13 [SIMPLE_EDGE]
+                  SHUFFLE [RS_103]
+                    PartitionCols:_col0, _col2, _col1, (_col6 + 1)
+                    Select Operator [SEL_29] (rows=191657247 width=135)
+                      Output:["_col0","_col1","_col2","_col5","_col6"]
+                      Filter Operator [FIL_164] (rows=191657247 width=135)
+                        predicate:rank_window_0 is not null
+                        PTF Operator [PTF_28] (rows=191657247 width=135)
+                          Function 
definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS 
FIRST, _col4 ASC NULLS FIRST","partition by:":"_col0, _col1, _col2"}]
+                          Select Operator [SEL_27] (rows=191657247 width=135)
+                            
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          <-Reducer 12 [SIMPLE_EDGE]
+                            SHUFFLE [RS_26]
+                              PartitionCols:_col0, _col1, _col2
+                              Select Operator [SEL_25] (rows=191657247 
width=135)
+                                
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                Group By Operator [GBY_24] (rows=191657247 
width=135)
+                                  
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                                <-Reducer 11 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_23]
+                                    PartitionCols:_col0, _col1, _col2, _col3, 
_col4
+                                    Group By Operator [GBY_22] (rows=383314495 
width=135)
+                                      
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)"],keys:_col5,
 _col6, _col8, _col10, _col11
+                                      Merge Join Operator [MERGEJOIN_182] 
(rows=383314495 width=135)
+                                        
Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col10","_col11"]
+                                      <-Map 22 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_81] 
(rows=462000 width=1436)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_179] 
(rows=462000 width=1436)
+                                              predicate:(i_brand is not null 
and i_category is not null and i_item_sk is not null)
+                                              TableScan [TS_79] (rows=462000 
width=1436)
+                                                
default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_brand","i_category"]
+                                      <-Reducer 10 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_18]
+                                          PartitionCols:_col2
+                                          Merge Join Operator [MERGEJOIN_181] 
(rows=348467716 width=135)
+                                            
Conds:RS_15._col1=RS_16._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8"]
+                                          <-Map 21 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_16]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_78] 
(rows=60 width=2045)
+                                                Output:["_col0","_col1"]
+                                                Filter Operator [FIL_178] 
(rows=60 width=2045)
+                                                  predicate:(cc_call_center_sk 
is not null and cc_name is not null)
+                                                  TableScan [TS_76] (rows=60 
width=2045)
+                                                    
default@call_center,call_center,Tbl:COMPLETE,Col:NONE,Output:["cc_call_center_sk","cc_name"]
+                                          <-Reducer 9 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_15]
+                                              PartitionCols:_col1
+                                              Merge Join Operator 
[MERGEJOIN_180] (rows=316788826 width=135)
+                                                
Conds:RS_12._col0=RS_13._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                              <-Map 1 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_12]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_72] 
(rows=287989836 width=135)
+                                                    
Output:["_col0","_col1","_col2","_col3"]
+                                                    Filter Operator [FIL_176] 
(rows=287989836 width=135)
+                                                      
predicate:(cs_call_center_sk is not null and cs_item_sk is not null and 
cs_sold_date_sk is not null)
+                                                      TableScan [TS_70] 
(rows=287989836 width=135)
+                                                        
default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_call_center_sk","cs_item_sk","cs_sales_price"]
+                                              <-Map 20 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_13]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_75] 
(rows=73048 width=1119)
+                                                    
Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_177] 
(rows=73048 width=1119)
+                                                      predicate:(((d_year = 
2000) or ((d_year = 1999) and (d_moy = 12)) or ((d_year = 2001) and (d_moy = 
1))) and d_date_sk is not null)
+                                                      TableScan [TS_73] 
(rows=73049 width=1119)
+                                                        
default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                <-Reducer 19 [SIMPLE_EDGE]
+                  SHUFFLE [RS_104]
+                    PartitionCols:_col0, _col2, _col1, _col7
+                    Select Operator [SEL_67] (rows=15971437 width=135)
+                      
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                      Filter Operator [FIL_169] (rows=15971437 width=135)
+                        predicate:CASE WHEN ((_col0 > 0)) THEN (((abs((_col6 - 
_col0)) / _col0) > 0.1)) ELSE (null) END
+                        Select Operator [SEL_66] (rows=31942874 width=135)
+                          
Output:["rank_window_1","_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                          Filter Operator [FIL_170] (rows=31942874 width=135)
+                            predicate:((_col0 > 0) and (_col4 = 2000) and 
rank_window_1 is not null)
+                            PTF Operator [PTF_65] (rows=191657247 width=135)
+                              Function 
definitions:[{},{"name:":"windowingtablefunction","order by:":"_col4 ASC NULLS 
FIRST, _col5 ASC NULLS FIRST","partition by:":"_col1, _col2, _col3"}]
+                              Select Operator [SEL_64] (rows=191657247 
width=135)
+                                
Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                              <-Reducer 18 [SIMPLE_EDGE]
+                                SHUFFLE [RS_63]
+                                  PartitionCols:_col0, _col1, _col2
+                                  Select Operator [SEL_62] (rows=191657247 
width=135)
+                                    
Output:["avg_window_0","_col0","_col1","_col2","_col3","_col4","_col5"]
+                                    PTF Operator [PTF_61] (rows=191657247 
width=135)
+                                      Function 
definitions:[{},{"name:":"windowingtablefunction","order by:":"_col0 ASC NULLS 
FIRST, _col1 ASC NULLS FIRST, _col2 ASC NULLS FIRST, _col3 ASC NULLS 
FIRST","partition by:":"_col0, _col1, _col2, _col3"}]
+                                      Select Operator [SEL_60] (rows=191657247 
width=135)
+                                        
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                      <-Reducer 17 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_59]
+                                          PartitionCols:_col0, _col1, _col2, 
_col3
+                                          Select Operator [SEL_58] 
(rows=191657247 width=135)
+                                            
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                            Group By Operator [GBY_57] 
(rows=191657247 width=135)
+                                              
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                                            <-Reducer 16 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_56]
+                                                PartitionCols:_col0, _col1, 
_col2, _col3, _col4
+                                                Group By Operator [GBY_55] 
(rows=383314495 width=135)
+                                                  
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)"],keys:_col5,
 _col6, _col8, _col10, _col11
+                                                  Merge Join Operator 
[MERGEJOIN_185] (rows=383314495 width=135)
+                                                    
Conds:RS_51._col2=RS_52._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col10","_col11"]
+                                                  <-Map 22 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_52]
+                                                      PartitionCols:_col0
+                                                       Please refer to the 
previous Select Operator [SEL_81]
+                                                  <-Reducer 15 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_51]
+                                                      PartitionCols:_col2
+                                                      Merge Join Operator 
[MERGEJOIN_184] (rows=348467716 width=135)
+                                                        
Conds:RS_48._col1=RS_49._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8"]
+                                                      <-Map 21 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_49]
+                                                          PartitionCols:_col0
+                                                           Please refer to the 
previous Select Operator [SEL_78]
+                                                      <-Reducer 14 
[SIMPLE_EDGE]
+                                                        SHUFFLE [RS_48]
+                                                          PartitionCols:_col1
+                                                          Merge Join Operator 
[MERGEJOIN_183] (rows=316788826 width=135)
+                                                            
Conds:RS_45._col0=RS_46._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                                          <-Map 1 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_45]
+                                                              
PartitionCols:_col0
+                                                               Please refer to 
the previous Select Operator [SEL_72]
+                                                          <-Map 20 
[SIMPLE_EDGE]
+                                                            SHUFFLE [RS_46]
+                                                              
PartitionCols:_col0
+                                                               Please refer to 
the previous Select Operator [SEL_75]
+                <-Reducer 6 [SIMPLE_EDGE]
+                  SHUFFLE [RS_105]
+                    PartitionCols:_col0, _col2, _col1, (_col6 - 1)
+                    Select Operator [SEL_99] (rows=191657247 width=135)
+                      Output:["_col0","_col1","_col2","_col5","_col6"]
+                      Filter Operator [FIL_175] (rows=191657247 width=135)
+                        predicate:rank_window_0 is not null
+                        PTF Operator [PTF_98] (rows=191657247 width=135)
+                          Function 
definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS 
FIRST, _col4 ASC NULLS FIRST","partition by:":"_col0, _col1, _col2"}]
+                          Select Operator [SEL_97] (rows=191657247 width=135)
+                            
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          <-Reducer 5 [SIMPLE_EDGE]
+                            SHUFFLE [RS_96]
+                              PartitionCols:_col0, _col1, _col2
+                              Select Operator [SEL_95] (rows=191657247 
width=135)
+                                
Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                Group By Operator [GBY_94] (rows=191657247 
width=135)
+                                  
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0,
 KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                                <-Reducer 4 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_93]
+                                    PartitionCols:_col0, _col1, _col2, _col3, 
_col4
+                                    Group By Operator [GBY_92] (rows=383314495 
width=135)
+                                      
Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)"],keys:_col5,
 _col6, _col8, _col10, _col11
+                                      Merge Join Operator [MERGEJOIN_188] 
(rows=383314495 width=135)
+                                        
Conds:RS_88._col2=RS_89._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col10","_col11"]
+                                      <-Map 22 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_89]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select 
Operator [SEL_81]
+                                      <-Reducer 3 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_88]
+                                          PartitionCols:_col2
+                                          Merge Join Operator [MERGEJOIN_187] 
(rows=348467716 width=135)
+                                            
Conds:RS_85._col1=RS_86._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8"]
+                                          <-Map 21 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_86]
+                                              PartitionCols:_col0
+                                               Please refer to the previous 
Select Operator [SEL_78]
+                                          <-Reducer 2 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_85]
+                                              PartitionCols:_col1
+                                              Merge Join Operator 
[MERGEJOIN_186] (rows=316788826 width=135)
+                                                
Conds:RS_82._col0=RS_83._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                              <-Map 1 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_82]
+                                                  PartitionCols:_col0
+                                                   Please refer to the 
previous Select Operator [SEL_72]
+                                              <-Map 20 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_83]
+                                                  PartitionCols:_col0
+                                                   Please refer to the 
previous Select Operator [SEL_75]
+

Reply via email to