hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [12/17] hive git commit: HIVE-16764: Support numeric as same as decimal (Pengcheng Xiong, reviewed by Ashutosh Chauhan)
Date Wed, 31 May 2017 00:11:50 GMT
http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query25.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query25.q.out b/ql/src/test/results/clientpositive/perf/query25.q.out
index 2b1c064..071e23e 100644
--- a/ql/src/test/results/clientpositive/perf/query25.q.out
+++ b/ql/src/test/results/clientpositive/perf/query25.q.out
@@ -1,6 +1,96 @@
-PREHOOK: query: explain select i_item_id ,i_item_desc ,s_store_id ,s_store_name ,sum(ss_net_profit) as store_sales_profit ,sum(sr_net_loss) as store_returns_loss ,sum(cs_net_profit) as catalog_sales_profit 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 = 1998 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 10 and d2.d_year = 1998 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_moy between 4 and 10 and d3.d_year = 1998 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: query: explain
+select  
+ i_item_id
+ ,i_item_desc
+ ,s_store_id
+ ,s_store_name
+ ,sum(ss_net_profit) as store_sales_profit
+ ,sum(sr_net_loss) as store_returns_loss
+ ,sum(cs_net_profit) as catalog_sales_profit
+ 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 = 2000
+ 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  10
+ and d2.d_year              = 2000
+ 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_moy               between 4 and  10 
+ and d3.d_year              = 2000
+ 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_net_profit) as store_sales_profit ,sum(sr_net_loss) as store_returns_loss ,sum(cs_net_profit) as catalog_sales_profit 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 = 1998 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 10 and d2.d_year = 1998 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_moy between 4 and 10 and d3.d_year = 1998 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: query: explain
+select  
+ i_item_id
+ ,i_item_desc
+ ,s_store_id
+ ,s_store_name
+ ,sum(ss_net_profit) as store_sales_profit
+ ,sum(sr_net_loss) as store_returns_loss
+ ,sum(cs_net_profit) as catalog_sales_profit
+ 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 = 2000
+ 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  10
+ and d2.d_year              = 2000
+ 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_moy               between 4 and  10 
+ and d3.d_year              = 2000
+ 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.
 
@@ -77,7 +167,7 @@ Stage-0
                                       Select Operator [SEL_17] (rows=4058 width=1119)
                                         Output:["_col0"]
                                         Filter Operator [FIL_91] (rows=4058 width=1119)
-                                          predicate:(d_moy BETWEEN 4 AND 10 and (d_year = 1998) and d_date_sk is not null)
+                                          predicate:(d_moy BETWEEN 4 AND 10 and (d_year = 2000) 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","d_moy"]
                                   <-Reducer 8 [SIMPLE_EDGE]
@@ -91,7 +181,7 @@ Stage-0
                                           Select Operator [SEL_14] (rows=18262 width=1119)
                                             Output:["_col0"]
                                             Filter Operator [FIL_90] (rows=18262 width=1119)
-                                              predicate:((d_moy = 4) and (d_year = 1998) and d_date_sk is not null)
+                                              predicate:((d_moy = 4) and (d_year = 2000) and d_date_sk is not null)
                                                Please refer to the previous TableScan [TS_3]
                                       <-Reducer 12 [SIMPLE_EDGE]
                                         SHUFFLE [RS_24]
@@ -127,7 +217,7 @@ Stage-0
                                 Select Operator [SEL_5] (rows=4058 width=1119)
                                   Output:["_col0"]
                                   Filter Operator [FIL_87] (rows=4058 width=1119)
-                                    predicate:(d_moy BETWEEN 4 AND 10 and (d_year = 1998) and d_date_sk is not null)
+                                    predicate:(d_moy BETWEEN 4 AND 10 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_37]

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query26.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query26.q.out b/ql/src/test/results/clientpositive/perf/query26.q.out
index 1c94c40..125dc77 100644
--- a/ql/src/test/results/clientpositive/perf/query26.q.out
+++ b/ql/src/test/results/clientpositive/perf/query26.q.out
@@ -1,6 +1,42 @@
-PREHOOK: query: explain select i_item_id, avg(cs_quantity) agg1, avg(cs_list_price) agg2, avg(cs_coupon_amt) agg3, avg(cs_sales_price) agg4 from catalog_sales, customer_demographics, date_dim, item, promotion where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and catalog_sales.cs_item_sk = item.i_item_sk and catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk and catalog_sales.cs_promo_sk = promotion.p_promo_sk and cd_gender = 'F' and cd_marital_status = 'W' and cd_education_status = 'Primary' and (p_channel_email = 'N' or p_channel_event = 'N') and d_year = 1998 group by i_item_id order by i_item_id limit 100
+PREHOOK: query: explain
+select  i_item_id, 
+        avg(cs_quantity) agg1,
+        avg(cs_list_price) agg2,
+        avg(cs_coupon_amt) agg3,
+        avg(cs_sales_price) agg4 
+ from catalog_sales, customer_demographics, date_dim, item, promotion
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd_demo_sk and
+       cs_promo_sk = p_promo_sk and
+       cd_gender = 'F' and 
+       cd_marital_status = 'W' and
+       cd_education_status = 'Primary' and
+       (p_channel_email = 'N' or p_channel_event = 'N') and
+       d_year = 1998 
+ group by i_item_id
+ order by i_item_id
+ limit 100
 PREHOOK: type: QUERY
-POSTHOOK: query: explain select i_item_id, avg(cs_quantity) agg1, avg(cs_list_price) agg2, avg(cs_coupon_amt) agg3, avg(cs_sales_price) agg4 from catalog_sales, customer_demographics, date_dim, item, promotion where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and catalog_sales.cs_item_sk = item.i_item_sk and catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk and catalog_sales.cs_promo_sk = promotion.p_promo_sk and cd_gender = 'F' and cd_marital_status = 'W' and cd_education_status = 'Primary' and (p_channel_email = 'N' or p_channel_event = 'N') and d_year = 1998 group by i_item_id order by i_item_id limit 100
+POSTHOOK: query: explain
+select  i_item_id, 
+        avg(cs_quantity) agg1,
+        avg(cs_list_price) agg2,
+        avg(cs_coupon_amt) agg3,
+        avg(cs_sales_price) agg4 
+ from catalog_sales, customer_demographics, date_dim, item, promotion
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd_demo_sk and
+       cs_promo_sk = p_promo_sk and
+       cd_gender = 'F' and 
+       cd_marital_status = 'W' and
+       cd_education_status = 'Primary' and
+       (p_channel_email = 'N' or p_channel_event = 'N') and
+       d_year = 1998 
+ group by i_item_id
+ order by i_item_id
+ limit 100
 POSTHOOK: type: QUERY
 Plan optimized by CBO.
 

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query28.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query28.q.out b/ql/src/test/results/clientpositive/perf/query28.q.out
index 78129cf..1fe7f15 100644
--- a/ql/src/test/results/clientpositive/perf/query28.q.out
+++ b/ql/src/test/results/clientpositive/perf/query28.q.out
@@ -1,5 +1,6 @@
 Warning: Shuffle Join MERGEJOIN[58][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 3' is a cross product
-PREHOOK: query: explain select  *
+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
@@ -50,7 +51,8 @@ from (select avg(ss_list_price) B1_LP
           or ss_wholesale_cost between 42 and 42+20)) B6
 limit 100
 PREHOOK: type: QUERY
-POSTHOOK: query: explain select  *
+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

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query29.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query29.q.out b/ql/src/test/results/clientpositive/perf/query29.q.out
index ec303d3..07306c0 100644
--- a/ql/src/test/results/clientpositive/perf/query29.q.out
+++ b/ql/src/test/results/clientpositive/perf/query29.q.out
@@ -1,6 +1,94 @@
-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 = 2 and d1.d_year = 2000 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 2 and 2 + 3 and d2.d_year = 2000 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 (2000,2000+1,2000+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: 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 = 2 and d1.d_year = 2000 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 2 and 2 + 3 and d2.d_year = 2000 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 (2000,2000+1,2000+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: 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.
 
@@ -77,7 +165,7 @@ Stage-0
                                       Select Operator [SEL_17] (rows=4058 width=1119)
                                         Output:["_col0"]
                                         Filter Operator [FIL_91] (rows=4058 width=1119)
-                                          predicate:(d_moy BETWEEN 2 AND 5 and (d_year = 2000) and d_date_sk is not null)
+                                          predicate:(d_moy BETWEEN 4 AND 7 and (d_year = 1999) and d_date_sk is not null)
                                           TableScan [TS_12] (rows=73049 width=1119)
                                             default@date_dim,d1,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
                                   <-Reducer 10 [SIMPLE_EDGE]
@@ -91,7 +179,7 @@ Stage-0
                                           Select Operator [SEL_14] (rows=18262 width=1119)
                                             Output:["_col0"]
                                             Filter Operator [FIL_90] (rows=18262 width=1119)
-                                              predicate:((d_moy = 2) and (d_year = 2000) and d_date_sk is not null)
+                                              predicate:((d_moy = 4) and (d_year = 1999) and d_date_sk is not null)
                                                Please refer to the previous TableScan [TS_12]
                                       <-Reducer 9 [SIMPLE_EDGE]
                                         SHUFFLE [RS_24]
@@ -136,7 +224,7 @@ Stage-0
                                 Select Operator [SEL_5] (rows=36525 width=1119)
                                   Output:["_col0"]
                                   Filter Operator [FIL_87] (rows=36525 width=1119)
-                                    predicate:((d_year) IN (2000, 2001, 2002) and d_date_sk is not null)
+                                    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/86b18772/ql/src/test/results/clientpositive/perf/query3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query3.q.out b/ql/src/test/results/clientpositive/perf/query3.q.out
index ba37c27..33bcb31 100644
--- a/ql/src/test/results/clientpositive/perf/query3.q.out
+++ b/ql/src/test/results/clientpositive/perf/query3.q.out
@@ -1,6 +1,42 @@
-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: 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: 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.
 

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query30.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query30.q.out b/ql/src/test/results/clientpositive/perf/query30.q.out
index abe92b5..a86f11d 100644
--- a/ql/src/test/results/clientpositive/perf/query30.q.out
+++ b/ql/src/test/results/clientpositive/perf/query30.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: explain with customer_total_return as
+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
@@ -27,7 +28,8 @@ PREHOOK: query: explain with customer_total_return as
                   ,c_last_review_date,ctr_total_return
 limit 100
 PREHOOK: type: QUERY
-POSTHOOK: query: explain with customer_total_return as
+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

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query31.q.out b/ql/src/test/results/clientpositive/perf/query31.q.out
index b456244..b3a74f3 100644
--- a/ql/src/test/results/clientpositive/perf/query31.q.out
+++ b/ql/src/test/results/clientpositive/perf/query31.q.out
@@ -1,301 +1,394 @@
-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 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 = 1998 and ss1.ca_county = ss2.ca_county and ss2.d_qoy = 2 and ss2.d_year = 1998 and ss2.ca_county = ss3.ca_county and ss3.d_qoy = 3 and ss3.d_year = 1998 and ss1.ca_county = ws1.ca_county and ws1.d_qoy = 1 a
 nd ws1.d_year = 1998 and ws1.ca_county = ws2.ca_county and ws2.d_qoy = 2 and ws2.d_year = 1998 and ws1.ca_county = ws3.ca_county and ws3.d_qoy = 3 and ws3.d_year =1998 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 web_q1_q2_increase
+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 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 = 1998 and ss1.ca_county = ss2.ca_county and ss2.d_qoy = 2 and ss2.d_year = 1998 and ss2.ca_county = ss3.ca_county and ss3.d_qoy = 3 and ss3.d_year = 1998 and ss1.ca_county = ws1.ca_county and ws1.d_qoy = 1 
 and ws1.d_year = 1998 and ws1.ca_county = ws2.ca_county and ws2.d_qoy = 2 and ws2.d_year = 1998 and ws1.ca_county = ws3.ca_county and ws3.d_qoy = 3 and ws3.d_year =1998 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 web_q1_q2_increase
+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 1 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
-Reducer 11 <- Map 24 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
-Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
-Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
-Reducer 15 <- Map 24 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
-Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
-Reducer 17 <- Reducer 16 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
-Reducer 18 <- Map 13 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
-Reducer 19 <- Map 24 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
-Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
-Reducer 20 <- Reducer 19 (SIMPLE_EDGE)
-Reducer 21 <- Map 13 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
-Reducer 22 <- Map 24 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
-Reducer 23 <- Reducer 22 (SIMPLE_EDGE)
-Reducer 3 <- Map 24 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+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 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE), Reducer 22 (SIMPLE_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 12 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
-Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
-Reducer 7 <- Map 1 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
-Reducer 8 <- Map 24 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
-Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 11 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE), Reducer 8 (SIMPLE_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 6
-      File Output Operator [FS_136]
-        Select Operator [SEL_134] (rows=287493839 width=88)
+      Reducer 5
+      File Output Operator [FS_133]
+        Select Operator [SEL_132] (rows=287493839 width=88)
           Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-        <-Reducer 5 [SIMPLE_EDGE]
-          SHUFFLE [RS_133]
-            Select Operator [SEL_132] (rows=287493839 width=88)
-              Output:["_col0","_col1","_col2","_col3","_col4"]
-              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_270] (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 12 [SIMPLE_EDGE]
-                  SHUFFLE [RS_127]
+          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 [SIMPLE_EDGE]
+              SHUFFLE [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_58] (rows=348477374 width=88)
+                    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_48] (rows=40000000 width=1014)
+                            Output:["_col0","_col1"]
+                            Filter Operator [FIL_244] (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_42] (rows=575995635 width=88)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_242] (rows=575995635 width=88)
+                                  predicate:(ss_sold_date_sk is not null and ss_addr_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 [SIMPLE_EDGE]
+                  SHUFFLE [RS_120]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_78] (rows=87121617 width=135)
                       Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                    <-Reducer 11 [SIMPLE_EDGE]
-                      SHUFFLE [RS_57]
+                    <-Reducer 14 [SIMPLE_EDGE]
+                      SHUFFLE [RS_77]
                         PartitionCols:_col0
-                        Group By Operator [GBY_56] (rows=696954748 width=88)
+                        Group By Operator [GBY_76] (rows=174243235 width=135)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_262] (rows=696954748 width=88)
-                            Conds:RS_52._col1=RS_53._col0(Inner),Output:["_col2","_col7"]
-                          <-Map 24 [SIMPLE_EDGE]
-                            SHUFFLE [RS_53]
+                          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
-                              Select Operator [SEL_48] (rows=40000000 width=1014)
+                              Select Operator [SEL_68] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
                                 Filter Operator [FIL_247] (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 10 [SIMPLE_EDGE]
-                            SHUFFLE [RS_52]
+                                   Please refer to the previous TableScan [TS_6]
+                          <-Reducer 13 [SIMPLE_EDGE]
+                            SHUFFLE [RS_72]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_261] (rows=633595212 width=88)
-                                Conds:RS_49._col0=RS_50._col0(Inner),Output:["_col1","_col2"]
-                              <-Map 13 [SIMPLE_EDGE]
-                                SHUFFLE [RS_50]
+                              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_45] (rows=18262 width=1119)
+                                  Select Operator [SEL_65] (rows=18262 width=1119)
                                     Output:["_col0"]
                                     Filter Operator [FIL_246] (rows=18262 width=1119)
-                                      predicate:((d_qoy = 3) and (d_year = 1998) and d_date_sk is not null)
-                                      TableScan [TS_3] (rows=73049 width=1119)
-                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_qoy"]
-                              <-Map 1 [SIMPLE_EDGE]
-                                SHUFFLE [RS_49]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_42] (rows=575995635 width=88)
-                                    Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_245] (rows=575995635 width=88)
-                                      predicate:(ss_sold_date_sk is not null and ss_addr_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 17 [SIMPLE_EDGE]
-                  SHUFFLE [RS_128]
-                    PartitionCols:_col0
-                    Merge Join Operator [MERGEJOIN_269] (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 16 [SIMPLE_EDGE]
-                      SHUFFLE [RS_120]
-                        PartitionCols:_col0
-                        Group By Operator [GBY_78] (rows=87121617 width=135)
-                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                        <-Reducer 15 [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_264] (rows=174243235 width=135)
-                                Conds:RS_72._col1=RS_73._col0(Inner),Output:["_col2","_col7"]
-                              <-Map 24 [SIMPLE_EDGE]
-                                SHUFFLE [RS_73]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_68] (rows=40000000 width=1014)
-                                    Output:["_col0","_col1"]
-                                    Filter Operator [FIL_250] (rows=40000000 width=1014)
-                                      predicate:(ca_address_sk is not null and ca_county is not null)
-                                       Please refer to the previous TableScan [TS_6]
-                              <-Reducer 14 [SIMPLE_EDGE]
-                                SHUFFLE [RS_72]
-                                  PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_263] (rows=158402938 width=135)
-                                    Conds:RS_69._col0=RS_70._col0(Inner),Output:["_col1","_col2"]
-                                  <-Map 13 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_70]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_65] (rows=18262 width=1119)
-                                        Output:["_col0"]
-                                        Filter Operator [FIL_249] (rows=18262 width=1119)
-                                          predicate:((d_qoy = 1) and (d_year = 1998) and d_date_sk is not null)
-                                           Please refer to the previous TableScan [TS_3]
-                                  <-Map 25 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_69]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_62] (rows=144002668 width=135)
-                                        Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_248] (rows=144002668 width=135)
-                                          predicate:(ws_sold_date_sk is not null and ws_bill_addr_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 20 [SIMPLE_EDGE]
-                      SHUFFLE [RS_121]
-                        PartitionCols:_col0
-                        Group By Operator [GBY_98] (rows=87121617 width=135)
-                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                        <-Reducer 19 [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_266] (rows=174243235 width=135)
-                                Conds:RS_92._col1=RS_93._col0(Inner),Output:["_col2","_col7"]
-                              <-Map 24 [SIMPLE_EDGE]
-                                SHUFFLE [RS_93]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_88] (rows=40000000 width=1014)
-                                    Output:["_col0","_col1"]
-                                    Filter Operator [FIL_253] (rows=40000000 width=1014)
-                                      predicate:(ca_address_sk is not null and ca_county is not null)
-                                       Please refer to the previous TableScan [TS_6]
-                              <-Reducer 18 [SIMPLE_EDGE]
-                                SHUFFLE [RS_92]
-                                  PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_265] (rows=158402938 width=135)
-                                    Conds:RS_89._col0=RS_90._col0(Inner),Output:["_col1","_col2"]
-                                  <-Map 13 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_90]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_85] (rows=18262 width=1119)
-                                        Output:["_col0"]
-                                        Filter Operator [FIL_252] (rows=18262 width=1119)
-                                          predicate:((d_qoy = 2) and (d_year = 1998) and d_date_sk is not null)
-                                           Please refer to the previous TableScan [TS_3]
-                                  <-Map 25 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_89]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_82] (rows=144002668 width=135)
-                                        Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_251] (rows=144002668 width=135)
-                                          predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
-                                           Please refer to the previous TableScan [TS_60]
-                    <-Reducer 23 [SIMPLE_EDGE]
-                      SHUFFLE [RS_122]
-                        PartitionCols:_col0
-                        Group By Operator [GBY_118] (rows=87121617 width=135)
-                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                        <-Reducer 22 [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_268] (rows=174243235 width=135)
-                                Conds:RS_112._col1=RS_113._col0(Inner),Output:["_col2","_col7"]
+                                      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_113]
+                                SHUFFLE [RS_69]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_108] (rows=40000000 width=1014)
-                                    Output:["_col0","_col1"]
-                                    Filter Operator [FIL_256] (rows=40000000 width=1014)
-                                      predicate:(ca_address_sk is not null and ca_county is not null)
-                                       Please refer to the previous TableScan [TS_6]
-                              <-Reducer 21 [SIMPLE_EDGE]
-                                SHUFFLE [RS_112]
-                                  PartitionCols:_col1
-                                  Merge Join Operator [MERGEJOIN_267] (rows=158402938 width=135)
-                                    Conds:RS_109._col0=RS_110._col0(Inner),Output:["_col1","_col2"]
-                                  <-Map 13 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_110]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_105] (rows=18262 width=1119)
-                                        Output:["_col0"]
-                                        Filter Operator [FIL_255] (rows=18262 width=1119)
-                                          predicate:((d_qoy = 3) and (d_year = 1998) and d_date_sk is not null)
-                                           Please refer to the previous TableScan [TS_3]
-                                  <-Map 25 [SIMPLE_EDGE]
-                                    SHUFFLE [RS_109]
-                                      PartitionCols:_col0
-                                      Select Operator [SEL_102] (rows=144002668 width=135)
-                                        Output:["_col0","_col1","_col2"]
-                                        Filter Operator [FIL_254] (rows=144002668 width=135)
-                                          predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
-                                           Please refer to the previous TableScan [TS_60]
-                <-Reducer 4 [SIMPLE_EDGE]
-                  SHUFFLE [RS_125]
+                                  Select Operator [SEL_62] (rows=144002668 width=135)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_245] (rows=144002668 width=135)
+                                      predicate:(ws_sold_date_sk is not null and ws_bill_addr_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 [SIMPLE_EDGE]
+                  SHUFFLE [RS_121]
                     PartitionCols:_col0
-                    Group By Operator [GBY_18] (rows=348477374 width=88)
+                    Group By Operator [GBY_98] (rows=87121617 width=135)
                       Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                    <-Reducer 3 [SIMPLE_EDGE]
-                      SHUFFLE [RS_17]
+                    <-Reducer 18 [SIMPLE_EDGE]
+                      SHUFFLE [RS_97]
                         PartitionCols:_col0
-                        Group By Operator [GBY_16] (rows=696954748 width=88)
+                        Group By Operator [GBY_96] (rows=174243235 width=135)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_258] (rows=696954748 width=88)
-                            Conds:RS_12._col1=RS_13._col0(Inner),Output:["_col2","_col7"]
-                          <-Map 24 [SIMPLE_EDGE]
-                            SHUFFLE [RS_13]
+                          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
-                              Select Operator [SEL_8] (rows=40000000 width=1014)
+                              Select Operator [SEL_88] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_241] (rows=40000000 width=1014)
+                                Filter Operator [FIL_250] (rows=40000000 width=1014)
                                   predicate:(ca_address_sk is not null and ca_county is not null)
                                    Please refer to the previous TableScan [TS_6]
-                          <-Reducer 2 [SIMPLE_EDGE]
-                            SHUFFLE [RS_12]
+                          <-Reducer 17 [SIMPLE_EDGE]
+                            SHUFFLE [RS_92]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_257] (rows=633595212 width=88)
-                                Conds:RS_9._col0=RS_10._col0(Inner),Output:["_col1","_col2"]
-                              <-Map 13 [SIMPLE_EDGE]
-                                SHUFFLE [RS_10]
+                              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_5] (rows=18262 width=1119)
+                                  Select Operator [SEL_85] (rows=18262 width=1119)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_240] (rows=18262 width=1119)
-                                      predicate:((d_qoy = 2) and (d_year = 1998) and d_date_sk is not null)
+                                    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 1 [SIMPLE_EDGE]
-                                SHUFFLE [RS_9]
+                              <-Map 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_89]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_2] (rows=575995635 width=88)
+                                  Select Operator [SEL_82] (rows=144002668 width=135)
                                     Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_239] (rows=575995635 width=88)
-                                      predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
-                                       Please refer to the previous TableScan [TS_0]
-                <-Reducer 9 [SIMPLE_EDGE]
-                  SHUFFLE [RS_126]
+                                    Filter Operator [FIL_248] (rows=144002668 width=135)
+                                      predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
+                                       Please refer to the previous TableScan [TS_60]
+                <-Reducer 22 [SIMPLE_EDGE]
+                  SHUFFLE [RS_122]
                     PartitionCols:_col0
-                    Group By Operator [GBY_38] (rows=348477374 width=88)
+                    Group By Operator [GBY_118] (rows=87121617 width=135)
                       Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
-                    <-Reducer 8 [SIMPLE_EDGE]
-                      SHUFFLE [RS_37]
+                    <-Reducer 21 [SIMPLE_EDGE]
+                      SHUFFLE [RS_117]
                         PartitionCols:_col0
-                        Group By Operator [GBY_36] (rows=696954748 width=88)
+                        Group By Operator [GBY_116] (rows=174243235 width=135)
                           Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col7
-                          Merge Join Operator [MERGEJOIN_260] (rows=696954748 width=88)
-                            Conds:RS_32._col1=RS_33._col0(Inner),Output:["_col2","_col7"]
-                          <-Map 24 [SIMPLE_EDGE]
-                            SHUFFLE [RS_33]
+                          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
-                              Select Operator [SEL_28] (rows=40000000 width=1014)
+                              Select Operator [SEL_108] (rows=40000000 width=1014)
                                 Output:["_col0","_col1"]
-                                Filter Operator [FIL_244] (rows=40000000 width=1014)
+                                Filter Operator [FIL_253] (rows=40000000 width=1014)
                                   predicate:(ca_address_sk is not null and ca_county is not null)
                                    Please refer to the previous TableScan [TS_6]
-                          <-Reducer 7 [SIMPLE_EDGE]
-                            SHUFFLE [RS_32]
+                          <-Reducer 20 [SIMPLE_EDGE]
+                            SHUFFLE [RS_112]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_259] (rows=633595212 width=88)
-                                Conds:RS_29._col0=RS_30._col0(Inner),Output:["_col1","_col2"]
-                              <-Map 13 [SIMPLE_EDGE]
-                                SHUFFLE [RS_30]
+                              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_25] (rows=18262 width=1119)
+                                  Select Operator [SEL_105] (rows=18262 width=1119)
                                     Output:["_col0"]
-                                    Filter Operator [FIL_243] (rows=18262 width=1119)
-                                      predicate:((d_qoy = 1) and (d_year = 1998) and d_date_sk is not null)
+                                    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 1 [SIMPLE_EDGE]
-                                SHUFFLE [RS_29]
+                              <-Map 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_109]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_22] (rows=575995635 width=88)
+                                  Select Operator [SEL_102] (rows=144002668 width=135)
                                     Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_242] (rows=575995635 width=88)
-                                      predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
-                                       Please refer to the previous TableScan [TS_0]
+                                    Filter Operator [FIL_251] (rows=144002668 width=135)
+                                      predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null)
+                                       Please refer to the previous TableScan [TS_60]
+            <-Reducer 4 [SIMPLE_EDGE]
+              SHUFFLE [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
+                          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)
+                               Please refer to the previous TableScan [TS_6]
+                      <-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
+                              Select Operator [SEL_2] (rows=575995635 width=88)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_236] (rows=575995635 width=88)
+                                  predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
+                                   Please refer to the previous TableScan [TS_0]
+            <-Reducer 8 [SIMPLE_EDGE]
+              SHUFFLE [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
+                          Select Operator [SEL_28] (rows=40000000 width=1014)
+                            Output:["_col0","_col1"]
+                            Filter Operator [FIL_241] (rows=40000000 width=1014)
+                              predicate:(ca_address_sk is not null and ca_county is not null)
+                               Please refer to the previous TableScan [TS_6]
+                      <-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
+                              Select Operator [SEL_22] (rows=575995635 width=88)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_239] (rows=575995635 width=88)
+                                  predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null)
+                                   Please refer to the previous TableScan [TS_0]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query32.q.out b/ql/src/test/results/clientpositive/perf/query32.q.out
index c9820b3..66b8485 100644
--- a/ql/src/test/results/clientpositive/perf/query32.q.out
+++ b/ql/src/test/results/clientpositive/perf/query32.q.out
@@ -1,130 +1,152 @@
-PREHOOK: query: explain SELECT sum(cs1.cs_ext_discount_amt) as excess_discount_amount
-FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                             cs.cs_ext_discount_amt as cs_ext_discount_amt
-             FROM catalog_sales cs
-             JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-             WHERE d.d_date between '2000-01-27' and '2000-04-27') cs1
-JOIN item i ON (i.i_item_sk = cs1.cs_item_sk)
-JOIN (SELECT cs2.cs_item_sk as cs_item_sk,
-                          1.3 * avg(cs_ext_discount_amt) as avg_cs_ext_discount_amt
-           FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                                        cs.cs_ext_discount_amt as cs_ext_discount_amt
-                        FROM catalog_sales cs
-                        JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-                        WHERE d.d_date between '2000-01-27' and '2000-04-27') cs2
-                        GROUP BY cs2.cs_item_sk) tmp1
-ON (i.i_item_sk = tmp1.cs_item_sk)
-WHERE i.i_manufact_id = 436 and
-               cs1.cs_ext_discount_amt > tmp1.avg_cs_ext_discount_amt
+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(cs1.cs_ext_discount_amt) as excess_discount_amount
-FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                             cs.cs_ext_discount_amt as cs_ext_discount_amt
-             FROM catalog_sales cs
-             JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-             WHERE d.d_date between '2000-01-27' and '2000-04-27') cs1
-JOIN item i ON (i.i_item_sk = cs1.cs_item_sk)
-JOIN (SELECT cs2.cs_item_sk as cs_item_sk,
-                          1.3 * avg(cs_ext_discount_amt) as avg_cs_ext_discount_amt
-           FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                                        cs.cs_ext_discount_amt as cs_ext_discount_amt
-                        FROM catalog_sales cs
-                        JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-                        WHERE d.d_date between '2000-01-27' and '2000-04-27') cs2
-                        GROUP BY cs2.cs_item_sk) tmp1
-ON (i.i_item_sk = tmp1.cs_item_sk)
-WHERE i.i_manufact_id = 436 and
-               cs1.cs_ext_discount_amt > tmp1.avg_cs_ext_discount_amt
+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 7 (SIMPLE_EDGE)
-Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
-Reducer 4 <- Map 8 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
-Reducer 5 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
-Reducer 6 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+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 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
-    limit:-1
+    limit:100
     Stage-1
-      Reducer 5
-      File Output Operator [FS_37]
-        Group By Operator [GBY_35] (rows=1 width=112)
-          Output:["_col0"],aggregations:["sum(VALUE._col0)"]
-        <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
-          PARTITION_ONLY_SHUFFLE [RS_34]
-            Group By Operator [GBY_33] (rows=1 width=112)
-              Output:["_col0"],aggregations:["sum(_col5)"]
-              Select Operator [SEL_32] (rows=232311810 width=135)
-                Output:["_col5"]
-                Filter Operator [FIL_31] (rows=232311810 width=135)
-                  predicate:(_col5 > _col1)
-                  Merge Join Operator [MERGEJOIN_59] (rows=696935432 width=135)
-                    Conds:RS_27._col0=RS_28._col0(Inner),RS_28._col0=RS_29._col0(Inner),Output:["_col1","_col5"]
-                  <-Map 8 [SIMPLE_EDGE]
-                    SHUFFLE [RS_28]
-                      PartitionCols:_col0
-                      Select Operator [SEL_16] (rows=231000 width=1436)
-                        Output:["_col0"]
-                        Filter Operator [FIL_54] (rows=231000 width=1436)
-                          predicate:((i_manufact_id = 436) and i_item_sk is not null)
-                          TableScan [TS_14] (rows=462000 width=1436)
-                            default@item,i,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_manufact_id"]
-                  <-Reducer 3 [SIMPLE_EDGE]
-                    SHUFFLE [RS_27]
-                      PartitionCols:_col0
-                      Select Operator [SEL_13] (rows=158394413 width=135)
-                        Output:["_col0","_col1"]
-                        Group By Operator [GBY_12] (rows=158394413 width=135)
-                          Output:["_col0","_col1"],aggregations:["avg(VALUE._col0)"],keys:KEY._col0
-                        <-Reducer 2 [SIMPLE_EDGE]
-                          SHUFFLE [RS_11]
-                            PartitionCols:_col0
-                            Group By Operator [GBY_10] (rows=316788826 width=135)
-                              Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col1
-                              Merge Join Operator [MERGEJOIN_57] (rows=316788826 width=135)
-                                Conds:RS_6._col0=RS_7._col0(Inner),Output:["_col1","_col2"]
-                              <-Map 1 [SIMPLE_EDGE]
-                                SHUFFLE [RS_6]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_2] (rows=287989836 width=135)
-                                    Output:["_col0","_col1","_col2"]
-                                    Filter Operator [FIL_52] (rows=287989836 width=135)
-                                      predicate:(cs_sold_date_sk is not null and cs_item_sk is not null)
-                                      TableScan [TS_0] (rows=287989836 width=135)
-                                        default@catalog_sales,cs,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_item_sk","cs_ext_discount_amt"]
-                              <-Map 7 [SIMPLE_EDGE]
-                                SHUFFLE [RS_7]
-                                  PartitionCols:_col0
-                                  Select Operator [SEL_5] (rows=8116 width=1119)
-                                    Output:["_col0"]
-                                    Filter Operator [FIL_53] (rows=8116 width=1119)
-                                      predicate:(d_date BETWEEN '2000-01-27' AND '2000-04-27' and d_date_sk is not null)
-                                      TableScan [TS_3] (rows=73049 width=1119)
-                                        default@date_dim,d,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_date"]
-                  <-Reducer 6 [SIMPLE_EDGE]
-                    SHUFFLE [RS_29]
-                      PartitionCols:_col0
-                      Select Operator [SEL_26] (rows=316788826 width=135)
-                        Output:["_col0","_col1"]
+      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_23._col0=RS_24._col0(Inner),Output:["_col1","_col2"]
+                          Conds:RS_27._col0=RS_28._col0(Inner),Output:["_col1","_col2"]
                         <-Map 1 [SIMPLE_EDGE]
-                          SHUFFLE [RS_23]
+                          SHUFFLE [RS_27]
                             PartitionCols:_col0
-                            Select Operator [SEL_19] (rows=287989836 width=135)
+                            Select Operator [SEL_2] (rows=287989836 width=135)
                               Output:["_col0","_col1","_col2"]
-                              Filter Operator [FIL_55] (rows=287989836 width=135)
-                                predicate:(cs_sold_date_sk is not null and cs_item_sk is not null)
-                                 Please refer to the previous TableScan [TS_0]
-                        <-Map 7 [SIMPLE_EDGE]
+                              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=8116 width=1119)
+                            Select Operator [SEL_22] (rows=231000 width=1436)
                               Output:["_col0"]
-                              Filter Operator [FIL_56] (rows=8116 width=1119)
-                                predicate:(d_date BETWEEN '2000-01-27' AND '2000-04-27' and d_date_sk is not null)
-                                 Please refer to the previous TableScan [TS_3]
+                              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 [SIMPLE_EDGE]
+                          SHUFFLE [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
+                                        Select Operator [SEL_8] (rows=287989836 width=135)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_55] (rows=287989836 width=135)
+                                            predicate:(cs_item_sk is not null and cs_sold_date_sk is not null)
+                                             Please refer to the previous TableScan [TS_0]
+                                    <-Map 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_13]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_11] (rows=8116 width=1119)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_56] (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)
+                                             Please refer to the previous TableScan [TS_3]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/86b18772/ql/src/test/results/clientpositive/perf/query33.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query33.q.out b/ql/src/test/results/clientpositive/perf/query33.q.out
index 00c021b..c1a5fa2 100644
--- a/ql/src/test/results/clientpositive/perf/query33.q.out
+++ b/ql/src/test/results/clientpositive/perf/query33.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: explain with ss as (
+PREHOOK: query: explain
+with ss as (
  select
           i_manufact_id,sum(ss_ext_sales_price) total_sales
  from
@@ -71,7 +72,8 @@ where i_category in ('Books'))
  order by total_sales
 limit 100
 PREHOOK: type: QUERY
-POSTHOOK: query: explain with ss as (
+POSTHOOK: query: explain
+with ss as (
  select
           i_manufact_id,sum(ss_ext_sales_price) total_sales
  from


Mime
View raw message