You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2017/01/10 20:53:28 UTC

[5/9] hive git commit: HIVE-15481 : Support multiple and nested subqueries (Vineet Garg via Ashutosh Chauhan) Signed-off-by: Ashutosh Chauhan

http://git-wip-us.apache.org/repos/asf/hive/blob/b0ed8241/ql/src/test/results/clientpositive/perf/query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query23.q.out b/ql/src/test/results/clientpositive/perf/query23.q.out
new file mode 100644
index 0000000..6d4cfca
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/query23.q.out
@@ -0,0 +1,383 @@
+PREHOOK: query: explain with frequent_ss_items as 
+ (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt
+  from store_sales
+      ,date_dim 
+      ,item
+  where ss_sold_date_sk = d_date_sk
+    and ss_item_sk = i_item_sk 
+    and d_year in (1999,1999+1,1999+2,1999+3)
+  group by substr(i_item_desc,1,30),i_item_sk,d_date
+  having count(*) >4),
+ max_store_sales as
+ (select max(csales) tpcds_cmax 
+  from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales
+        from store_sales
+            ,customer
+            ,date_dim 
+        where ss_customer_sk = c_customer_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year in (1999,1999+1,1999+2,1999+3) 
+        group by c_customer_sk) x),
+ best_ss_customer as
+ (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales
+  from store_sales
+      ,customer
+  where ss_customer_sk = c_customer_sk
+  group by c_customer_sk
+  having sum(ss_quantity*ss_sales_price) > (95/100.0))
+  select  sum(sales)
+ from (select cs_quantity*cs_list_price sales
+       from catalog_sales
+           ,date_dim 
+       where d_year = 1999 
+         and d_moy = 1 
+         and cs_sold_date_sk = d_date_sk 
+         and cs_item_sk in (select item_sk from frequent_ss_items)
+         and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer)
+      union all
+      select ws_quantity*ws_list_price sales
+       from web_sales 
+           ,date_dim 
+       where d_year = 1999 
+         and d_moy = 1 
+         and ws_sold_date_sk = d_date_sk 
+         and ws_item_sk in (select item_sk from frequent_ss_items)
+         and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) y
+ limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: explain with frequent_ss_items as 
+ (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt
+  from store_sales
+      ,date_dim 
+      ,item
+  where ss_sold_date_sk = d_date_sk
+    and ss_item_sk = i_item_sk 
+    and d_year in (1999,1999+1,1999+2,1999+3)
+  group by substr(i_item_desc,1,30),i_item_sk,d_date
+  having count(*) >4),
+ max_store_sales as
+ (select max(csales) tpcds_cmax 
+  from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales
+        from store_sales
+            ,customer
+            ,date_dim 
+        where ss_customer_sk = c_customer_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year in (1999,1999+1,1999+2,1999+3) 
+        group by c_customer_sk) x),
+ best_ss_customer as
+ (select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales
+  from store_sales
+      ,customer
+  where ss_customer_sk = c_customer_sk
+  group by c_customer_sk
+  having sum(ss_quantity*ss_sales_price) > (95/100.0))
+  select  sum(sales)
+ from (select cs_quantity*cs_list_price sales
+       from catalog_sales
+           ,date_dim 
+       where d_year = 1999 
+         and d_moy = 1 
+         and cs_sold_date_sk = d_date_sk 
+         and cs_item_sk in (select item_sk from frequent_ss_items)
+         and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer)
+      union all
+      select ws_quantity*ws_list_price sales
+       from web_sales 
+           ,date_dim 
+       where d_year = 1999 
+         and d_moy = 1 
+         and ws_sold_date_sk = d_date_sk 
+         and ws_item_sk in (select item_sk from frequent_ss_items)
+         and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) y
+ limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 13 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 17 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 19 <- Map 18 (SIMPLE_EDGE), Map 22 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (SIMPLE_EDGE), Reducer 26 (SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (SIMPLE_EDGE), Reducer 31 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 24 <- Map 23 (SIMPLE_EDGE), Map 27 (SIMPLE_EDGE)
+Reducer 25 <- Map 28 (SIMPLE_EDGE), Reducer 24 (SIMPLE_EDGE)
+Reducer 26 <- Reducer 25 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 11 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 29 (SIMPLE_EDGE), Map 32 (SIMPLE_EDGE)
+Reducer 31 <- Reducer 30 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 16 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 9 <- Map 12 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6
+      File Output Operator [FS_136]
+        Limit [LIM_135] (rows=1 width=112)
+          Number of rows:100
+          Group By Operator [GBY_133] (rows=1 width=112)
+            Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+          <-Union 5 [SIMPLE_EDGE]
+            <-Reducer 21 [CONTAINS]
+              Reduce Output Operator [RS_132]
+                Group By Operator [GBY_131] (rows=1 width=112)
+                  Output:["_col0"],aggregations:["sum(_col0)"]
+                  Select Operator [SEL_127] (rows=191667562 width=135)
+                    Output:["_col0"]
+                    Merge Join Operator [MERGEJOIN_206] (rows=191667562 width=135)
+                      Conds:RS_124._col2=RS_125._col0(Inner),Output:["_col3","_col4"]
+                    <-Reducer 20 [SIMPLE_EDGE]
+                      SHUFFLE [RS_124]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_204] (rows=174243235 width=135)
+                          Conds:RS_121._col1=RS_122._col0(Inner),Output:["_col2","_col3","_col4"]
+                        <-Reducer 19 [SIMPLE_EDGE]
+                          SHUFFLE [RS_121]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_199] (rows=158402938 width=135)
+                              Conds:RS_118._col0=RS_119._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            <-Map 18 [SIMPLE_EDGE]
+                              SHUFFLE [RS_118]
+                                PartitionCols:_col0
+                                Select Operator [SEL_66] (rows=144002668 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                  Filter Operator [FIL_186] (rows=144002668 width=135)
+                                    predicate:ws_sold_date_sk is not null
+                                    TableScan [TS_64] (rows=144002668 width=135)
+                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:NONE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk","ws_quantity","ws_list_price"]
+                            <-Map 22 [SIMPLE_EDGE]
+                              SHUFFLE [RS_119]
+                                PartitionCols:_col0
+                                Select Operator [SEL_69] (rows=18262 width=1119)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_187] (rows=18262 width=1119)
+                                    predicate:((d_year = 1999) and (d_moy = 1) and d_date_sk is not null)
+                                    TableScan [TS_67] (rows=73049 width=1119)
+                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                        <-Reducer 26 [SIMPLE_EDGE]
+                          SHUFFLE [RS_122]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_95] (rows=58079562 width=88)
+                              Output:["_col0"],keys:_col1
+                              Select Operator [SEL_91] (rows=116159124 width=88)
+                                Output:["_col1"]
+                                Filter Operator [FIL_90] (rows=116159124 width=88)
+                                  predicate:(_col3 > 4)
+                                  Select Operator [SEL_193] (rows=348477374 width=88)
+                                    Output:["_col0","_col3"]
+                                    Group By Operator [GBY_89] (rows=348477374 width=88)
+                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                    <-Reducer 25 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_88]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_87] (rows=696954748 width=88)
+                                          Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                          Select Operator [SEL_85] (rows=696954748 width=88)
+                                            Output:["_col0","_col1","_col2"]
+                                            Merge Join Operator [MERGEJOIN_201] (rows=696954748 width=88)
+                                              Conds:RS_82._col1=RS_83._col0(Inner),Output:["_col3","_col5","_col6"]
+                                            <-Map 28 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_83]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_78] (rows=462000 width=1436)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_190] (rows=462000 width=1436)
+                                                    predicate:i_item_sk is not null
+                                                    TableScan [TS_76] (rows=462000 width=1436)
+                                                      default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_desc"]
+                                            <-Reducer 24 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_82]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_200] (rows=633595212 width=88)
+                                                  Conds:RS_79._col0=RS_80._col0(Inner),Output:["_col1","_col3"]
+                                                <-Map 23 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_79]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_72] (rows=575995635 width=88)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_188] (rows=575995635 width=88)
+                                                        predicate:(ss_sold_date_sk is not null and ss_item_sk is not null)
+                                                        TableScan [TS_70] (rows=575995635 width=88)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk"]
+                                                <-Map 27 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_80]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_75] (rows=36525 width=1119)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_189] (rows=36525 width=1119)
+                                                        predicate:((d_year) IN (1999, 2000, 2001, 2002) 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_date","d_year"]
+                    <-Reducer 31 [SIMPLE_EDGE]
+                      SHUFFLE [RS_125]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_116] (rows=52799601 width=88)
+                          Output:["_col0"],keys:_col0
+                          Select Operator [SEL_112] (rows=105599202 width=88)
+                            Output:["_col0"]
+                            Filter Operator [FIL_111] (rows=105599202 width=88)
+                              predicate:(_col1 > 0.95)
+                              Group By Operator [GBY_110] (rows=316797606 width=88)
+                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                              <-Reducer 30 [SIMPLE_EDGE]
+                                SHUFFLE [RS_109]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_108] (rows=633595212 width=88)
+                                    Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                                    Select Operator [SEL_106] (rows=633595212 width=88)
+                                      Output:["_col0","_col1"]
+                                      Merge Join Operator [MERGEJOIN_202] (rows=633595212 width=88)
+                                        Conds:RS_103._col0=RS_104._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 29 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_103]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_99] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_191] (rows=575995635 width=88)
+                                              predicate:ss_customer_sk is not null
+                                              TableScan [TS_97] (rows=575995635 width=88)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
+                                      <-Map 32 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_104]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_102] (rows=80000000 width=860)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_192] (rows=80000000 width=860)
+                                              predicate:c_customer_sk is not null
+                                              TableScan [TS_100] (rows=80000000 width=860)
+                                                default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk"]
+            <-Reducer 4 [CONTAINS]
+              Reduce Output Operator [RS_132]
+                Group By Operator [GBY_131] (rows=1 width=112)
+                  Output:["_col0"],aggregations:["sum(_col0)"]
+                  Select Operator [SEL_63] (rows=383314495 width=135)
+                    Output:["_col0"]
+                    Merge Join Operator [MERGEJOIN_205] (rows=383314495 width=135)
+                      Conds:RS_60._col1=RS_61._col0(Inner),Output:["_col3","_col4"]
+                    <-Reducer 16 [SIMPLE_EDGE]
+                      SHUFFLE [RS_61]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_52] (rows=52799601 width=88)
+                          Output:["_col0"],keys:_col0
+                          Select Operator [SEL_48] (rows=105599202 width=88)
+                            Output:["_col0"]
+                            Filter Operator [FIL_47] (rows=105599202 width=88)
+                              predicate:(_col1 > 0.95)
+                              Group By Operator [GBY_46] (rows=316797606 width=88)
+                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                              <-Reducer 15 [SIMPLE_EDGE]
+                                SHUFFLE [RS_45]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_44] (rows=633595212 width=88)
+                                    Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                                    Select Operator [SEL_42] (rows=633595212 width=88)
+                                      Output:["_col0","_col1"]
+                                      Merge Join Operator [MERGEJOIN_198] (rows=633595212 width=88)
+                                        Conds:RS_39._col0=RS_40._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 14 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_39]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_35] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_184] (rows=575995635 width=88)
+                                              predicate:ss_customer_sk is not null
+                                              TableScan [TS_33] (rows=575995635 width=88)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
+                                      <-Map 17 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_40]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_38] (rows=80000000 width=860)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_185] (rows=80000000 width=860)
+                                              predicate:c_customer_sk is not null
+                                              TableScan [TS_36] (rows=80000000 width=860)
+                                                default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk"]
+                    <-Reducer 3 [SIMPLE_EDGE]
+                      SHUFFLE [RS_60]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_203] (rows=348467716 width=135)
+                          Conds:RS_57._col2=RS_58._col0(Inner),Output:["_col1","_col3","_col4"]
+                        <-Reducer 11 [SIMPLE_EDGE]
+                          SHUFFLE [RS_58]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_31] (rows=58079562 width=88)
+                              Output:["_col0"],keys:_col1
+                              Select Operator [SEL_27] (rows=116159124 width=88)
+                                Output:["_col1"]
+                                Filter Operator [FIL_26] (rows=116159124 width=88)
+                                  predicate:(_col3 > 4)
+                                  Select Operator [SEL_194] (rows=348477374 width=88)
+                                    Output:["_col0","_col3"]
+                                    Group By Operator [GBY_25] (rows=348477374 width=88)
+                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                    <-Reducer 10 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_24]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_23] (rows=696954748 width=88)
+                                          Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                          Select Operator [SEL_21] (rows=696954748 width=88)
+                                            Output:["_col0","_col1","_col2"]
+                                            Merge Join Operator [MERGEJOIN_197] (rows=696954748 width=88)
+                                              Conds:RS_18._col1=RS_19._col0(Inner),Output:["_col3","_col5","_col6"]
+                                            <-Map 13 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_19]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_14] (rows=462000 width=1436)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_183] (rows=462000 width=1436)
+                                                    predicate:i_item_sk is not null
+                                                    TableScan [TS_12] (rows=462000 width=1436)
+                                                      default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_desc"]
+                                            <-Reducer 9 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_18]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_196] (rows=633595212 width=88)
+                                                  Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col1","_col3"]
+                                                <-Map 12 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_16]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_11] (rows=36525 width=1119)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_182] (rows=36525 width=1119)
+                                                        predicate:((d_year) IN (1999, 2000, 2001, 2002) and d_date_sk is not null)
+                                                        TableScan [TS_9] (rows=73049 width=1119)
+                                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_date","d_year"]
+                                                <-Map 8 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_15]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_8] (rows=575995635 width=88)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_181] (rows=575995635 width=88)
+                                                        predicate:(ss_sold_date_sk is not null and ss_item_sk is not null)
+                                                        TableScan [TS_6] (rows=575995635 width=88)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:NONE,Output:["ss_sold_date_sk","ss_item_sk"]
+                        <-Reducer 2 [SIMPLE_EDGE]
+                          SHUFFLE [RS_57]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_195] (rows=316788826 width=135)
+                              Conds:RS_54._col0=RS_55._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            <-Map 1 [SIMPLE_EDGE]
+                              SHUFFLE [RS_54]
+                                PartitionCols:_col0
+                                Select Operator [SEL_2] (rows=287989836 width=135)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                  Filter Operator [FIL_179] (rows=287989836 width=135)
+                                    predicate:cs_sold_date_sk is not null
+                                    TableScan [TS_0] (rows=287989836 width=135)
+                                      default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:NONE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity","cs_list_price"]
+                            <-Map 7 [SIMPLE_EDGE]
+                              SHUFFLE [RS_55]
+                                PartitionCols:_col0
+                                Select Operator [SEL_5] (rows=18262 width=1119)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_180] (rows=18262 width=1119)
+                                    predicate:((d_year = 1999) and (d_moy = 1) 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/b0ed8241/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
new file mode 100644
index 0000000..e42c685
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/query33.q.out
@@ -0,0 +1,437 @@
+PREHOOK: query: -- start query 1 in stream 0 using template query33.tpl and seed 1930872976
+explain with ss as (
+ select
+          i_manufact_id,sum(ss_ext_sales_price) total_sales
+ from
+ 	store_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ group by i_manufact_id),
+ cs as (
+ select
+          i_manufact_id,sum(cs_ext_sales_price) total_sales
+ from
+ 	catalog_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ group by i_manufact_id),
+ ws as (
+ select
+          i_manufact_id,sum(ws_ext_sales_price) total_sales
+ from
+ 	web_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ group by i_manufact_id)
+  select  i_manufact_id ,sum(total_sales) total_sales
+ from  (select * from ss 
+        union all
+        select * from cs 
+        union all
+        select * from ws) tmp1
+ group by i_manufact_id
+ order by total_sales
+limit 100
+PREHOOK: type: QUERY
+POSTHOOK: query: -- start query 1 in stream 0 using template query33.tpl and seed 1930872976
+explain with ss as (
+ select
+          i_manufact_id,sum(ss_ext_sales_price) total_sales
+ from
+ 	store_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ group by i_manufact_id),
+ cs as (
+ select
+          i_manufact_id,sum(cs_ext_sales_price) total_sales
+ from
+ 	catalog_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ group by i_manufact_id),
+ ws as (
+ select
+          i_manufact_id,sum(ws_ext_sales_price) total_sales
+ from
+ 	web_sales,
+ 	date_dim,
+         customer_address,
+         item
+ where
+         i_manufact_id               in (select
+  i_manufact_id
+from
+ item
+where i_category in ('Books'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 3
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ group by i_manufact_id)
+  select  i_manufact_id ,sum(total_sales) total_sales
+ from  (select * from ss 
+        union all
+        select * from cs 
+        union all
+        select * from ws) tmp1
+ group by i_manufact_id
+ order by total_sales
+limit 100
+POSTHOOK: type: QUERY
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 11 <- Map 10 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 12 <- Map 14 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 20 <- Map 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 23 <- Map 25 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 27 <- Map 26 (SIMPLE_EDGE), Reducer 31 (SIMPLE_EDGE)
+Reducer 28 <- Reducer 27 (SIMPLE_EDGE), Reducer 34 (SIMPLE_EDGE)
+Reducer 29 <- Reducer 28 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 3 <- Reducer 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 31 <- Map 30 (SIMPLE_EDGE)
+Reducer 33 <- Map 32 (SIMPLE_EDGE), Map 35 (SIMPLE_EDGE)
+Reducer 34 <- Map 36 (SIMPLE_EDGE), Reducer 33 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7
+      File Output Operator [FS_122]
+        Limit [LIM_121] (rows=100 width=108)
+          Number of rows:100
+          Select Operator [SEL_120] (rows=335408073 width=108)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_119]
+              Group By Operator [GBY_117] (rows=335408073 width=108)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 18 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (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 17 [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_184] (rows=383314495 width=135)
+                              Conds:RS_66._col0=RS_67._col4(Inner),Output:["_col1","_col8"]
+                            <-Reducer 16 [SIMPLE_EDGE]
+                              SHUFFLE [RS_66]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_177] (rows=508200 width=1436)
+                                  Conds:RS_63._col1=RS_64._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_63]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_39] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_164] (rows=462000 width=1436)
+                                        predicate:i_item_sk is not null
+                                        TableScan [TS_37] (rows=462000 width=1436)
+                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_manufact_id"]
+                                <-Reducer 20 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_64]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_45] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 19 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_44]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_43] (rows=231000 width=1436)
+                                          Output:["_col0"],keys:i_manufact_id
+                                          Select Operator [SEL_42] (rows=231000 width=1436)
+                                            Output:["i_manufact_id"]
+                                            Filter Operator [FIL_165] (rows=231000 width=1436)
+                                              predicate:(i_category) IN ('Books')
+                                              TableScan [TS_40] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_category","i_manufact_id"]
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_67]
+                                PartitionCols:_col4
+                                Select Operator [SEL_62] (rows=348467716 width=135)
+                                  Output:["_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_179] (rows=348467716 width=135)
+                                    Conds:RS_59._col1=RS_60._col0(Inner),Output:["_col2","_col3"]
+                                  <-Map 25 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_60]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_55] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_168] (rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -6) and ca_address_sk is not null)
+                                          TableScan [TS_53] (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_178] (rows=316788826 width=135)
+                                        Conds:RS_56._col0=RS_57._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_56]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_49] (rows=287989836 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_166] (rows=287989836 width=135)
+                                              predicate:(cs_sold_date_sk is not null and cs_bill_addr_sk is not null and cs_item_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"]
+                                      <-Map 24 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_57]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_52] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_167] (rows=18262 width=1119)
+                                              predicate:((d_year = 1999) and (d_moy = 3) and d_date_sk is not null)
+                                              TableScan [TS_50] (rows=73049 width=1119)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                <-Reducer 29 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (rows=670816147 width=108)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_111] (rows=95833781 width=135)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 28 [SIMPLE_EDGE]
+                        SHUFFLE [RS_110]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_109] (rows=191667562 width=135)
+                            Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_185] (rows=191667562 width=135)
+                              Conds:RS_105._col0=RS_106._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 27 [SIMPLE_EDGE]
+                              SHUFFLE [RS_105]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_180] (rows=508200 width=1436)
+                                  Conds:RS_102._col1=RS_103._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 26 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_102]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_78] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_169] (rows=462000 width=1436)
+                                        predicate:i_item_sk is not null
+                                        TableScan [TS_76] (rows=462000 width=1436)
+                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_manufact_id"]
+                                <-Reducer 31 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_103]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_84] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 30 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_83]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_82] (rows=231000 width=1436)
+                                          Output:["_col0"],keys:i_manufact_id
+                                          Select Operator [SEL_81] (rows=231000 width=1436)
+                                            Output:["i_manufact_id"]
+                                            Filter Operator [FIL_170] (rows=231000 width=1436)
+                                              predicate:(i_category) IN ('Books')
+                                              TableScan [TS_79] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_category","i_manufact_id"]
+                            <-Reducer 34 [SIMPLE_EDGE]
+                              SHUFFLE [RS_106]
+                                PartitionCols:_col3
+                                Select Operator [SEL_101] (rows=174243235 width=135)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_182] (rows=174243235 width=135)
+                                    Conds:RS_98._col2=RS_99._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 36 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_99]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_94] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_173] (rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -6) and ca_address_sk is not null)
+                                          TableScan [TS_92] (rows=40000000 width=1014)
+                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_gmt_offset"]
+                                  <-Reducer 33 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_98]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_181] (rows=158402938 width=135)
+                                        Conds:RS_95._col0=RS_96._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 32 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_95]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_88] (rows=144002668 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_171] (rows=144002668 width=135)
+                                              predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null and ws_item_sk is not null)
+                                              TableScan [TS_86] (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"]
+                                      <-Map 35 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_96]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_91] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_172] (rows=18262 width=1119)
+                                              predicate:((d_year = 1999) and (d_moy = 3) and d_date_sk is not null)
+                                              TableScan [TS_89] (rows=73049 width=1119)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                <-Reducer 4 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (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_183] (rows=766650239 width=88)
+                              Conds:RS_29._col0=RS_30._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 12 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col3
+                                Select Operator [SEL_25] (rows=696954748 width=88)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_176] (rows=696954748 width=88)
+                                    Conds:RS_22._col2=RS_23._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 14 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_23]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_18] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_163] (rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -6) 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 11 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_22]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_175] (rows=633595212 width=88)
+                                        Conds:RS_19._col0=RS_20._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 10 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_12] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_161] (rows=575995635 width=88)
+                                              predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null and ss_item_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"]
+                                      <-Map 13 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_20]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_15] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_162] (rows=18262 width=1119)
+                                              predicate:((d_year = 1999) and (d_moy = 3) 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"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_174] (rows=508200 width=1436)
+                                  Conds:RS_26._col1=RS_27._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_26]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_2] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_159] (rows=462000 width=1436)
+                                        predicate: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_manufact_id"]
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_27]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_8] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_7]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_6] (rows=231000 width=1436)
+                                          Output:["_col0"],keys:i_manufact_id
+                                          Select Operator [SEL_5] (rows=231000 width=1436)
+                                            Output:["i_manufact_id"]
+                                            Filter Operator [FIL_160] (rows=231000 width=1436)
+                                              predicate:(i_category) IN ('Books')
+                                              TableScan [TS_3] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_category","i_manufact_id"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b0ed8241/ql/src/test/results/clientpositive/perf/query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query56.q.out b/ql/src/test/results/clientpositive/perf/query56.q.out
new file mode 100644
index 0000000..2db6bfb
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/query56.q.out
@@ -0,0 +1,421 @@
+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 11 <- Map 10 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 12 <- Map 14 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 20 <- Map 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 23 <- Map 25 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 27 <- Map 26 (SIMPLE_EDGE), Reducer 31 (SIMPLE_EDGE)
+Reducer 28 <- Reducer 27 (SIMPLE_EDGE), Reducer 34 (SIMPLE_EDGE)
+Reducer 29 <- Reducer 28 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 3 <- Reducer 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 31 <- Map 30 (SIMPLE_EDGE)
+Reducer 33 <- Map 32 (SIMPLE_EDGE), Map 35 (SIMPLE_EDGE)
+Reducer 34 <- Map 36 (SIMPLE_EDGE), Reducer 33 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7
+      File Output Operator [FS_122]
+        Limit [LIM_121] (rows=100 width=108)
+          Number of rows:100
+          Select Operator [SEL_120] (rows=335408073 width=108)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_119]
+              Group By Operator [GBY_117] (rows=335408073 width=108)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 18 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (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 17 [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_184] (rows=383314495 width=135)
+                              Conds:RS_66._col0=RS_67._col4(Inner),Output:["_col1","_col8"]
+                            <-Reducer 16 [SIMPLE_EDGE]
+                              SHUFFLE [RS_66]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_177] (rows=508200 width=1436)
+                                  Conds:RS_63._col1=RS_64._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_63]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_39] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_164] (rows=462000 width=1436)
+                                        predicate:i_item_sk is not null
+                                        TableScan [TS_37] (rows=462000 width=1436)
+                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id"]
+                                <-Reducer 20 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_64]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_45] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 19 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_44]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_43] (rows=231000 width=1436)
+                                          Output:["_col0"],keys:i_item_id
+                                          Select Operator [SEL_42] (rows=231000 width=1436)
+                                            Output:["i_item_id"]
+                                            Filter Operator [FIL_165] (rows=231000 width=1436)
+                                              predicate:(i_color) IN ('orchid', 'chiffon', 'lace')
+                                              TableScan [TS_40] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_id","i_color"]
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_67]
+                                PartitionCols:_col4
+                                Select Operator [SEL_62] (rows=348467716 width=135)
+                                  Output:["_col4","_col5"]
+                                  Merge Join Operator [MERGEJOIN_179] (rows=348467716 width=135)
+                                    Conds:RS_59._col1=RS_60._col0(Inner),Output:["_col2","_col3"]
+                                  <-Map 25 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_60]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_55] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_168] (rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -8) and ca_address_sk is not null)
+                                          TableScan [TS_53] (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_178] (rows=316788826 width=135)
+                                        Conds:RS_56._col0=RS_57._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_56]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_49] (rows=287989836 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_166] (rows=287989836 width=135)
+                                              predicate:(cs_sold_date_sk is not null and cs_bill_addr_sk is not null and cs_item_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"]
+                                      <-Map 24 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_57]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_52] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_167] (rows=18262 width=1119)
+                                              predicate:((d_year = 2000) and (d_moy = 1) and d_date_sk is not null)
+                                              TableScan [TS_50] (rows=73049 width=1119)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                <-Reducer 29 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (rows=670816147 width=108)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_111] (rows=95833781 width=135)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 28 [SIMPLE_EDGE]
+                        SHUFFLE [RS_110]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_109] (rows=191667562 width=135)
+                            Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_185] (rows=191667562 width=135)
+                              Conds:RS_105._col0=RS_106._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 27 [SIMPLE_EDGE]
+                              SHUFFLE [RS_105]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_180] (rows=508200 width=1436)
+                                  Conds:RS_102._col1=RS_103._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 26 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_102]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_78] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_169] (rows=462000 width=1436)
+                                        predicate:i_item_sk is not null
+                                        TableScan [TS_76] (rows=462000 width=1436)
+                                          default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_sk","i_item_id"]
+                                <-Reducer 31 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_103]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_84] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 30 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_83]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_82] (rows=231000 width=1436)
+                                          Output:["_col0"],keys:i_item_id
+                                          Select Operator [SEL_81] (rows=231000 width=1436)
+                                            Output:["i_item_id"]
+                                            Filter Operator [FIL_170] (rows=231000 width=1436)
+                                              predicate:(i_color) IN ('orchid', 'chiffon', 'lace')
+                                              TableScan [TS_79] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_id","i_color"]
+                            <-Reducer 34 [SIMPLE_EDGE]
+                              SHUFFLE [RS_106]
+                                PartitionCols:_col3
+                                Select Operator [SEL_101] (rows=174243235 width=135)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_182] (rows=174243235 width=135)
+                                    Conds:RS_98._col2=RS_99._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 36 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_99]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_94] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_173] (rows=20000000 width=1014)
+                                          predicate:((ca_gmt_offset = -8) and ca_address_sk is not null)
+                                          TableScan [TS_92] (rows=40000000 width=1014)
+                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_gmt_offset"]
+                                  <-Reducer 33 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_98]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_181] (rows=158402938 width=135)
+                                        Conds:RS_95._col0=RS_96._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 32 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_95]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_88] (rows=144002668 width=135)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_171] (rows=144002668 width=135)
+                                              predicate:(ws_sold_date_sk is not null and ws_bill_addr_sk is not null and ws_item_sk is not null)
+                                              TableScan [TS_86] (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"]
+                                      <-Map 35 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_96]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_91] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_172] (rows=18262 width=1119)
+                                              predicate:((d_year = 2000) and (d_moy = 1) and d_date_sk is not null)
+                                              TableScan [TS_89] (rows=73049 width=1119)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year","d_moy"]
+                <-Reducer 4 [CONTAINS]
+                  Reduce Output Operator [RS_116]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_115] (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_183] (rows=766650239 width=88)
+                              Conds:RS_29._col0=RS_30._col3(Inner),Output:["_col1","_col8"]
+                            <-Reducer 12 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col3
+                                Select Operator [SEL_25] (rows=696954748 width=88)
+                                  Output:["_col3","_col5"]
+                                  Merge Join Operator [MERGEJOIN_176] (rows=696954748 width=88)
+                                    Conds:RS_22._col2=RS_23._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 14 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_23]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_18] (rows=20000000 width=1014)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_163] (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 11 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_22]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_175] (rows=633595212 width=88)
+                                        Conds:RS_19._col0=RS_20._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 10 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_19]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_12] (rows=575995635 width=88)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_161] (rows=575995635 width=88)
+                                              predicate:(ss_sold_date_sk is not null and ss_addr_sk is not null and ss_item_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"]
+                                      <-Map 13 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_20]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_15] (rows=18262 width=1119)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_162] (rows=18262 width=1119)
+                                              predicate:((d_year = 2000) and (d_moy = 1) 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"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_174] (rows=508200 width=1436)
+                                  Conds:RS_26._col1=RS_27._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_26]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_2] (rows=462000 width=1436)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_159] (rows=462000 width=1436)
+                                        predicate: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 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_27]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_8] (rows=115500 width=1436)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_7]
+                                        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_160] (rows=231000 width=1436)
+                                              predicate:(i_color) IN ('orchid', 'chiffon', 'lace')
+                                              TableScan [TS_3] (rows=462000 width=1436)
+                                                default@item,item,Tbl:COMPLETE,Col:NONE,Output:["i_item_id","i_color"]
+